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
31
votes
2 answers

How to search between two dates in LINQ to Entity?

I have an example in SQL how to use the same logic in Linq to Entity? SELECT * FROM TABLE WHERE DATE BETWEEN STARTDATE AND ENDDATE
Hrom
  • 319
  • 1
  • 3
  • 3
31
votes
4 answers

Only parameterless constructors and initializers are supported in LINQ to Entities message

I have a method that returns data from an EF model. I'm getting the above message, but I can't wotk our how to circumvent the problem. public static IEnumerable GetFundedCount() { var today = DateTime.Now; var…
dotnetnoob
  • 10,783
  • 20
  • 57
  • 103
31
votes
4 answers

How to use LINQ to select into an object?

I have data that looks like so: UserId | SongId -------- -------- 1 1 1 4 1 12 2 95 I also have the following class: class SongsForUser { public int User; public List Songs; } What I would like…
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
30
votes
4 answers

How to OrderBy an integer in a string field in a Linq query

I have some data coming out of an DB that I can't readily change the schema of. I want to sort it and bind it to a control based on a numerical ID. The problem is that the API stores the number in a string field instead of as an int and Linq barfs…
30
votes
4 answers

inner join in linq to entities

I have entity called Customer and it has three properties: public class Customer { public virtual Guid CompanyId; public virtual long Id; public virtual string Name; } I have also entity called Splitting and it has three…
Naor
  • 23,465
  • 48
  • 152
  • 268
30
votes
4 answers

Semaphore exception - Adding the specified count to the semaphore would cause it to exceed its maximum count

I've been having this SemaphoreFullException for quiet some time. To summarize.. I have hosted an application on IIS 7.5 with ASP.NET v4.0 framework Application Pool (integrated). I am using windows authentication to authenticate my users through…
Ali Haider
  • 467
  • 1
  • 6
  • 15
30
votes
5 answers

Cleanest Way To Map Entity To DTO With Linq Select?

I've been trying to come up with a clean and reusable way to map entities to their DTOs. Here is an example of what I've come up with and where I'm stuck. Entities public class Person { public int ID { get; set; } public string Name {…
Bacon
  • 783
  • 2
  • 11
  • 31
29
votes
3 answers

Sequence contains more than one element - SingleOrDefault not helping

I have the line below but still get an exception "Sequence contains more than one element" Details rd = this.db.Details.SingleOrDefault(x => x.TId == Id && x.TypeId == TypeId); I was hoping that SingleOrDefault would avoid the exception.
StackTrace
  • 9,190
  • 36
  • 114
  • 202
29
votes
3 answers

Distinct on Multiple Columns Entity Framework LINQ

What is the LINQ Equivalent of Select DISTINCT A, B, C from TESTDB WHERE ALPHA =1 I am trying something like this: var data = TESTDB.WHERE(i=>i.ALPHA==1).SELECT(A,B,C).DISTINCT();
Nanu
  • 3,010
  • 10
  • 38
  • 52
29
votes
2 answers

Expression.Invoke in Entity Framework?

The Entity Framework does not support the Expression.Invoke operator. You receive the following exception when trying to use it: "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities. Has anyone got a workaround for this…
Brad Leach
  • 16,857
  • 17
  • 72
  • 88
28
votes
1 answer

The entity or complex type ' ' cannot be constructed in a LINQ to Entities query

Possible Duplicate: The entity cannot be constructed in a LINQ to Entities query var tasks = from i in data.Incidents join a in data.Accounts on i.CustomerID equals a.Acct_CID select new Tasks() …
Chazt3n
  • 1,641
  • 3
  • 17
  • 42
27
votes
2 answers

Instantiating a context in LINQ to Entities

I've seen two different manners that programmers approach when creating an entity context in their code. The first is like such, and you can find it all over the MSDN code examples: public void DoSomething() { using (TaxableEducationEntities…
Jagd
  • 7,169
  • 22
  • 74
  • 107
27
votes
1 answer

Include() in LINQ to Entities query

I have the following models in my ASP.NET MVC 3 project: public class Task { public int Id { get; set; } public DateTime CreatedOn { get; set; } public TaskStatus Status { get; set; } } public class TaskStatus { public int Id { get;…
nunaxe
  • 1,432
  • 2
  • 15
  • 16
27
votes
5 answers

Linq-to-Entities Include method not found

I am using EF4 within a MVC3 application and I was looking for a way to view all my contacts within a given workgroup. In the controller I specified: var wg = from w in _repo.Workgroups.Include("Contact").ToList(); but I get the following…
jdiaz
  • 7,354
  • 12
  • 42
  • 51
27
votes
1 answer

"SELECT VALUE" - value keyword in LINQ/Entity Framework query

What does the keyword "value" mean in this statement, and where would I go to learn more? What happens if I leave out the keyword "value"? In the code below, z is an entity framework class. string queryString = "SELECT VALUE q from x.zs as q where…
NealWalters
  • 17,197
  • 42
  • 141
  • 251