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
90
votes
7 answers

How do I get the max ID with Linq to Entity?

I have a table User which has an identity column UserID, now what is the correct Linq to Entity line of code that would return me the max UserID? I've tried: using (MyDBEntities db = new MyDBEntities()) { var User = db.Users.Last(); // or …
Ray
  • 12,101
  • 27
  • 95
  • 137
87
votes
10 answers

'Contains()' workaround using Linq to Entities?

I'm trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does anyone know of a workaround to Contains not being supported? I want to do…
James Bloomer
  • 5,212
  • 2
  • 22
  • 23
84
votes
14 answers

Bulk-deleting in LINQ to Entities

Is there any way to bulk-delete a bunch of objects matching a given query in LINQ or LINQ-to-Entities? The only references that I can find are outdated, and it seems silly to iterate over and manually delete all objects I wish to remove.
Benjamin Pollack
  • 27,594
  • 16
  • 81
  • 105
84
votes
4 answers

The type of one of the expressions in the join clause is incorrect in Entity Framework

While trying to execute this query: var query = from dpr in ctx.DPR_MM join q in ctx.QOT on dpr.DPR_QOT_ID equals qot_id join p in ctx.PAY_MM on new { q.QOT_SEC_ID, dpr.DPR_TS } equals new { p.PAY_SEC_ID, p.PAY_DATE } …
MaMu
  • 1,837
  • 4
  • 20
  • 36
84
votes
7 answers

The specified type member is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported

var result = (from bd in context.tblBasicDetails from pd in context.tblPersonalDetails.Where(x => x.UserId == bd.UserId).DefaultIfEmpty() from opd in context.tblOtherPersonalDetails.Where(x => x.UserId == bd.UserId).DefaultIfEmpty() …
Sarang Amrutkar
  • 873
  • 1
  • 7
  • 10
76
votes
4 answers

"The LINQ expression node type 'Invoke' is not supported in LINQ to Entities" - stumped!

In my EF later, I'm trying to pass in an anonymous function to be used as part of my Linq query. The function would pass in an INT and return a BOOL (u.RelationTypeId is an INT). Below is a simplified version of my function: public…
Ryan Peters
  • 7,608
  • 8
  • 41
  • 57
71
votes
7 answers

LEFT JOIN in LINQ to entities?

I'm trying out LINQ to entities. I have a problem with the following: I want it to do this: SELECT T_Benutzer.BE_User ,T_Benutzer_Benutzergruppen.BEBG_BE FROM T_Benutzer LEFT JOIN T_Benutzer_Benutzergruppen ON…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
70
votes
8 answers

Error 3002: Problem in mapping fragments | c# linq to entities

I have a console application and what I'm trying to do is that every time the appllication runs, the date and time is sent to a table within my database. The table structure is like so: FTPRuns ID int Last Run datetime Simple enough. I've…
109221793
  • 16,477
  • 38
  • 108
  • 160
68
votes
6 answers

LINQ to Entities for subtracting 2 dates

I am trying to determine the number of days between 2 dates using LINQ with Entity Framework. It is telling me that it does not recognize Subtract on the System.TimeSpan class Here is my where portion of the LINQ query. where…
Michael I
68
votes
24 answers

Doesn't Linq to SQL miss the point? Aren't ORM-mappers (SubSonic, etc.) sub-optimal solutions?

I'd like the community's take on some thoughts I've had about Linq to Sql and other ORM mappers. I like Linq to Sql and the idea of expressing data access logic (or CRUD operations in general) in your native development tongue rather than having to…
Mark Brittingham
  • 28,545
  • 12
  • 80
  • 110
68
votes
4 answers

Dynamic query with OR conditions in Entity Framework

I am creating an application that searches the database and allows the user to dynamically add any criteria (around 50 possible), much like the following SO question: Creating dynamic queries with entity framework. I currently have working a search…
Ben Anderson
  • 7,003
  • 4
  • 40
  • 40
66
votes
1 answer

Entity Framework mergeoption notracking bad performance

I have a strange behavior trying to execute a query declaring ObjectQuery MergeOption to "NoTracking", in this case entity framework should not attach any entity and not create the relative ObjectStateEntry to track entity state. The problem is that…
MaRuf
  • 1,834
  • 2
  • 19
  • 22
64
votes
10 answers

Linq where clause compare only date value without time value

var _My_ResetSet_Array = _DB .tbl_MyTable .Where(x => x.Active == true && x.DateTimeValueColumn <= DateTime.Now) .Select(x => x); Upper query is working correct. But I want to check only date value only. But upper query check…
Frank Myat Thu
  • 4,448
  • 9
  • 67
  • 113
63
votes
6 answers

The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities

public List GetpathsById(List id) { long[] aa = id.ToArray(); long x; List paths = new List(); for (int i = 0; i < id.Count; i++) { x = id[i]; Presentation press =…
Artur Keyan
  • 7,643
  • 12
  • 52
  • 65
59
votes
5 answers

What is difference between .edmx and .dbml file in linq?

What is difference between .edmx and .dbml file in linq?In VS 2008 which datasource is best choice where edmx or dbml?Any problem will arise using edmx file in VS 2008?Can i use edmx in VS-2008?
user649802
  • 3,243
  • 3
  • 20
  • 14