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

Grouping/Subquery in LINQ to Entities with related ungrouped columns

I have this table in DB: ID | Timestamp | Score ------|---------------------|------------------- 1 | 2013-01-01 12:00:00 | 15 1 | 2013-01-02 11:00:00 | 1 1 | 2013-01-03 16:00:00 | 4 2 | 2013-01-08 04:00:00 | 7 2 |…
Kornelije Petak
  • 9,412
  • 15
  • 68
  • 96
3
votes
1 answer

Simple DbSet.Find() Call Taking Forever

I am getting terrible performance from a DbSet.Find() call. My code looks like this: public class Area { [Key] public string Id { get; protected set; } // ... } public class MyContext : DbContext { //... public DbSet
daveaglick
  • 3,600
  • 31
  • 45
3
votes
1 answer

EntityFramework Linq To Entities bitfield / boolean issue

I'm baffled as to why the following happens: The scenario is that within Stcoxrefs (which is a pure entity not a derived version) there are two bit fields. Using the following the int, char, varchar fields are correct but the bit fields are always…
Paul Zahra
  • 9,522
  • 8
  • 54
  • 76
3
votes
1 answer

Linq-To-Entities Include

I'm currently learning a bit more about Linq-To-Entities - particularly at the moment about eager and lazy loading. proxy.User.Include("Role").First(u => u.UserId == userId) This is supposed to load the User, along with any roles that user has. I…
Paul
  • 9,409
  • 13
  • 64
  • 113
3
votes
1 answer

Get dynamic OrderBy in LINQ

I am using datatables in quite a few pages in my ASP.NET MVC 3 site. They use server side paging and now I want to implement sorting based on the column headers. Datatables comes with iSortCol_0 which is an int value of what column is clicked. I…
Ctrl_Alt_Defeat
  • 3,933
  • 12
  • 66
  • 116
3
votes
1 answer

How do I delete one or more rows from my table using Linq to Entities *without* retrieving the rows first?

I understand I can map a delete stored procedure to the delete method for a particular type. However, this requires passing in a retrieved object to my context's DeleteObject method. This is bad enough, but what if I want to delete 2000 rows? Can I…
joshcomley
  • 28,099
  • 24
  • 107
  • 147
3
votes
1 answer

How does this work? LINQ to Entities triggers loading of assemblies?

Projects in solution I have a typical 3-tier solution that targets .NET 4.5 and uses Entity Framework 6 Alpha 3. The solution is made up of three projects, let's call them: Entities - class library containing the EF model and entity…
Daan
  • 6,952
  • 4
  • 29
  • 36
3
votes
2 answers

More efficient way of loading children of entity objects in linq to entity query

I have a rather complex linq to entity query that I'm performing, in the end, I have a result set. I loop through that result set, build business objects and return that list of business objects. it's pretty quick, the problem is that 2 of the child…
TheRedDwarf
  • 183
  • 1
  • 13
3
votes
2 answers

LINQ cast int64 issue

I need this linq query to work but linq is complaining about customercontact and phone being int64s and I also need to concat the second column but I'm afraid that isn't working for the same reason. If I add a tostring() it just says linq doesn't…
Preston
  • 1,300
  • 1
  • 17
  • 32
3
votes
2 answers

Simplest approach to a dynamic where clause

I'm hitting information overload when it comes to generating dynamic where clauses in EF. Some of the solutions look to be very dated (I'm targeting .NET 4.5 with EF 5). Here's what I have: public enum PersonTypes { Lazy = 1, Awesome = 2, …
mbursill
  • 2,911
  • 1
  • 32
  • 44
3
votes
1 answer

What would be a reasonably fast way to code this sql query in c#?

I have this SQL query: select sum(h.nbHeures) from Heures h join HeuresProjets hp on h.HpGuid=hp.HPId join ActivityCodes ac on h.Code=ac.ActivityId join MainDoeuvre mdo on ac.ActivityId=mdo.CodeGuid where hp.ExtraGuid…
0xFF
  • 808
  • 1
  • 12
  • 33
3
votes
2 answers

Linq To Entities Compare Value Against List

I am using Entity Framework 5.0, and I have a problem with a LINQ query. I have the following method that accepts an integer value which is then passed into the query. This works fine. public IList GetStandardReport(int…
tcode
  • 5,055
  • 19
  • 65
  • 124
3
votes
1 answer

Linq include children from collection

Using the include method does not include the children of a collection. var abuseCaseQuery = from @event in context.AbuseEvents.Include("AbuseCase.AbuseCaseStatus.Status") select new { @event.SecurityGroupId, @event.AbuseCaseId, …
Tim Blackwell
  • 699
  • 1
  • 7
  • 18
3
votes
2 answers

FirstOrDefault two ways

I can not understand the difference between these two ways of setting FirstOrDefault: Product a = (from r in _context.Products where r.IDPROD.Equals(10) select r).FirstOrDefault(); Product a = (from s in _context.Products where s.IDPROD == 10 select…
Roby G.
  • 95
  • 1
  • 1
  • 9
3
votes
1 answer

Generate dynamic select lambda expressions

I am somewhat new to expression trees and I just don't quite understand some things. What I need to do is send in a list of values and select the columns for an entity from those values. So I would make a call something like this: DATASTORE
cjohns
  • 1,520
  • 2
  • 14
  • 21