Obfuscated Scenario: A person has zero, one or many pets.
Using Linq to Sql, the need is to get an IQueryable list of pets for the given personID.
Here's the poorly mangled/butchered/obfuscated portion of the ERD:
Code:
public IQueryable<Pet> GetPersonPets(int personID)
{
var personPets= from p in Person
where ...
I am trying to get the first item in the database that has the a given 'UserGuid', but the 'First' extension method is throwing the following exception: System.InvalidOperationException: Sequence contains no elements
Here are some examples of what works and what does not:
// Works
var FoundUser1 = MyEntities.Users.First();
// Works
va...
I been wondering about this for a while. It seems like there are so many ways now I don't know when to use what? Or if there is even a point to learn them. Like I don't know if they basically do all the same things and just basically stick with one till you master it then maybe look at other ones.
So when I was taking an ASP.NET course ...
I've looked all around and spent way to long trying to convert this SQL statement into a Linq statement in VB. I'm sure it would be a good example for others out there - the statement is trying to pull products that have a many-to-many relationship with product categories, and the categories have a hierarchy of parents/children.
Here is...
Having played with Linq (to SQL and Objects) as well as the Entity Framework from Microsoft recently, I was wondering what the non-.Net (specifically Java) equivalents are?
...
I have a web app that creates a DataContext at the beginning of the request and lets go at the end.
I would like to have some handy stats for each page like
- number of inserts and time spent
- number of deletes and time spent
- number of updates and time spent
- number of selects and time spent
I have it all set for inserts/updates/de...
Is there any LINQ-like project for Python that can automatically query XML files and/or RDBMS tables? The syntax does not have to be exactly like LINQ in C#, but hopefully close in a pythonic way.
...
It seems there are two ways to build queries -- either using query expressions:
IEnumerable<Customer> result =
from customer in customers
where customer.FirstName == "Donna"
select customer;
or using extension methods:
IEnumerable<Customer> result =
...
Hi folks. I could not find the answer amongst the many posts on Linq, so here I am.
We have a client-server application, where the client side has absolutely no knowledge of the actual DAL on the server side, which is incidentally implemented using NHibernate. Meaning, there is no references to NHibernate from the client side assemblies,...
I felt like the following should be possible I'm just not sure what approach to take.
What I'd like to do is use the include method to shape my results, ie define how far along the object graph to traverse. but... I'd like that traversal to be conditional.
something like...
dealerships
.include( d => d.parts.where(p => p.price < 1...
Hi,
I'm putting together a presentation to show some of the productivity gains that I think C# may offer over C++. I've written some code in C# which I'd like to convert to C++. I don't have the time or up to date C++ to do the conversion justice, hence posting here.
Code to convert:
using System.Collections.Generic;
using System.Dr...
Linq in general, has extensions methods(at IEnumerable) like Where, Select, OrderBy. But use another methods like string.StartsWith.
Where can I find a list with all methods supported, for Linq to SQL and Linq to Entities?
...
Hi,
I am trying to execute the following query but I get the wrong results back.
foreach (var item in (from project in db.Projects
where project.Id == pProjectId
from task in project.Tasks
from taskItem in task.TaskItems
...
Hey,
I am using LINQ to access my database, and thereby gets a LINQ-created object which I want to send to the browser (this is a webservice) as a JSON-object. This works well by now, but when I add some testdata to the database (about 10-20 entries in each table) this fails miserably. The reason is that the LINQ-object contains all the...
hi im getting Index was outside the bounds of the array when i go to insert a linq statement
> slot_tbl_Schedule slot = new slot_tbl_Schedule
{
OrderID = int.Parse(lblOut.Text),
FromTime = DateTimeValue,
ToTime = DateTimeValue.AddMinutes(30),
BookedDate = DateTi...
I have RANDOM error (1 from 100 page loads) in following line of code:
topic = TopicsContext.GetCurrentDataContext().tTopics.Where(t => t.ContentId == contentId).SingleOrDefault();
Both ContentId property and conntentId local variables are long.
Most important - error occurs randomly, in most cases it works fine.
Thanks in advance ...
Please help.
I am trying to figure out how to use DATE or DATETIME for comparison in a linq query.
Example:
If I wanted all Employee names for those who started before today, I would do something like this in SQL:
SQL ------
Select
EmployeeNameColumn
From
EmployeeTable
WHERE StartDateColumn.Date <= GETDATE() //Today
SQL ------
But w...
I'm binding a linq Query to a datagridview for the purposes of allowing a user to insert/update/delete. However I'd like to hide the Id column. but I'd rather not hard code the
datagridview.columns[id].visible=false
In the event the id column name changes. I've read that you can walk through reflection to get a run-time list of colum...
Here's my Class that I'm grouping:
public class RefundTran : DataObjectBase<RefundTran>
{
public string ARTranID { get; set; }
public decimal Amount { get; set; }
public string ARTranTypeCode { get; set; }
public int CheckNumber { get; set; }
public int CustID { get; set; }
public stri...
I have a unique requirement that I hope is possible with LINQ to SQL.
First off, I am extending an older application so I am stuck with current database column names and the existing LINQ entity classes.
I have a LINQ wrapper with the following method:
public T Get(int id) where T : class, IEntity {
...
}
IEntity looks like:
publ...