Questions tagged [linq-to-entities]

This tag is for questions about LINQ to Entities, which means LINQ queries using the ADO.NET Entity Framework. Note that this is different than LINQ to SQL or other LINQ providers.

This tag is for questions about LINQ to Entities, which means LINQ queries using the ADO.NET Entity Framework. Note that this is different than LINQ to SQL or other LINQ providers.

Related Links

6860 questions
3
votes
1 answer

Can you select all child collections of a collection of entities as a single collection?

I have a collection of "ParentEntity", each one of which has a collection of "ChildEntity". I'd like to select ALL of the ChildEntity as a single collection. var children = from p in parents select p.Children; Returns a collection of ChildEntity…
BlueChippy
  • 5,935
  • 16
  • 81
  • 131
3
votes
1 answer

Null checking in LINQ Expression for SQL

I have been tasked with creating LINQ expressions for Automapper, which must be able to be turned into an SQL expression. This means no method calls, which is where I am having problems. I have a record with two columns of interest -…
Tim
  • 2,968
  • 5
  • 29
  • 55
3
votes
1 answer

Linq to Entities does not recognize the method System.DateTime.. and cannot translate this into a store expression

I have a problem that has taken me weeks to resolve and I have not been able to. I have a class where I have two methods. The following is supposed to take the latest date from database. That date represents the latest payment that a customer has…
Stefan S
  • 267
  • 2
  • 6
  • 12
3
votes
3 answers

MVC 4 - How to return a linq to entity query result in a view

Using the next code in my controller Index action, I try to display 2 fields contents in a razor view: public class MyController : Controller { private MyEntities db = new MyEntities(); public ActionResult Index() { …
Sami-L
  • 5,553
  • 18
  • 59
  • 87
3
votes
2 answers

Get the Max Length of a column in Entity Framework

When I import a Database to my EDMX Model I get the following information regards to the Max Length In the image above, I have String column with the Max Length of 250 Is there a way to check (while coding) this max length, without the need to look…
3
votes
1 answer

Selecting last record by linq fails with "method not recognised"

i have following query to select the last record in the database using (Entities ent = new Entities()) { Loaction last = (from x in ent.Locations select x).Last(); Location add = new Location(); add.id = last.id+1; //some more stuff } the following…
Vogel612
  • 5,620
  • 5
  • 48
  • 73
3
votes
2 answers

Performance issue on query over nested recursive objects

I'm wondering what is the best way to select from a nested hierarchy of objects? Assume that we a class MyRecursiveObject as below: public class MyRecursiveObject { public Int64 Id { get; set; } public MyRecursiveObject Parent { get; set; } …
M.Mohammadi
  • 1,558
  • 1
  • 13
  • 25
3
votes
1 answer

LINQ GroupBy throwing errors

var devSum = repository.Devices .Where(dev => dev.Id == deviceId) .Join(repository.ManagementGroups, device => device.ManagementGroupId, mGroup => mGroup.Id, (device, mGroup) => new { device, mGroup.Name }) …
DavidB
  • 2,566
  • 3
  • 33
  • 63
3
votes
3 answers

Multiple value comparisons in Linq to SQL

Has anyone got a tidier way of doing this with linq to entities? I am trying to get the item in each group that has the highest X, Y or Z e.g. Max( X, Y, Z ) var points = from g in groupedData from ep in g where (ep.X >…
Void
  • 265
  • 1
  • 3
  • 11
3
votes
1 answer

Return Only Child Entity Linq Entity Framework

Given something like: public class Parent { public int Id { get; set; } public List Children { get; set; } } // There is no reference to the parent in the object model public class Child { public int Id { get; set; } public…
Eric J.
  • 147,927
  • 63
  • 340
  • 553
3
votes
1 answer

Convert IQueryable List to Generic List?

I am trying to call GetScanningLogOnSettings(), which queries the ScanningDepartments table to get the departments, then creates an instance of ApplicationLogOnModel, assigns the queried results to a variable within the ApplicationLogOnModel, and…
Mark Saluta
  • 577
  • 1
  • 5
  • 12
3
votes
1 answer

Linq-To-Entities 'Contains' clause 1-many relationship

Consider a (simplified) table structure like this: [USERS] EMPID NAME [APPOINTMENTS] (FK_APPT_USER) EMPID APPTTYPEID COMPLETE Each user can have 0..* appointments, each of which can be one of many APPTYPEID's, and can either be complete or…
NMR
  • 166
  • 8
3
votes
1 answer

Need work around for case Insensitive Linq to Entity Framework query

I have three tables Users, UserRoles, Roles. columns of Usres Table are UserId(Pk varchar(20)), CashCenterId(Int) columns of UserRoles are UserRoleID(pk Int), UserId(Fk to user table), RoleID(Fk to role Table) columns of Roles are RoleId(Pk int),…
Yagnesh.Dixit
  • 318
  • 7
  • 18
3
votes
3 answers

Does Linq to Entities 4.0 have Fulltext capabilities?

Just wanted to know if Linq to entities 4.0 have fulltext search capabilities? Thanks
user161433
  • 4,419
  • 5
  • 32
  • 55
3
votes
1 answer

How to do "let" in dynamic LINQ?

How would I write this query in dynamic linq? I know how to do the select, but how do I do the "let"? var qry = from sr in data.Addresses let AddressType_Desc = sr.AddressType.AddressType_Desc let Country_Desc =…
Jonathan
  • 1,725
  • 3
  • 19
  • 45