How to combine 3 tables using entity framework and LINQ?

What are the smart decisions in the design of LINQ and the Entity Framework?

  • Answer:

    A2A. There's a lot to write as answer to these huge topics and your question would be better served if it targeted a more specific issue. you should return IQueryable<T>  from your database linq queries, as opposed to IEnumerable<T>. There's a huge performance gain when using the former, so use that when you know that there will be further expanding of the collection ( e.g. further .Where(x=> blahCondition) executed on the database, executing that on an IQueryable is much better than on an IEnumerable). consider implementing the Repository and Unit of Work patterns when you use EF, to make unit testing easier, and respectively to avoid entering a world of hair-pulling, many-hours-spending on "where the hell is this context error coming from" type of issues. EF is very nice but if you don't pay attention to understanding its context gotchas, it will make your life a living hell.  If you need help understanding these patterns you can ask a specific related question and i can expand. If bullet point 1 is difficult to understand, here's more: The difference between IEnumerable<User> lst1 = dbContext.Users.Where(user => user.Age < 30); lst1.Take(2); and IQueryable<User> lst2 = dbContext.Users.Where(user => user.Age < 30); lst2.Take(2); is deferred execution in the second case. In the first query you get the entire table of users that fulfill the age condition in memory, from which your list takes 2 afterwards, whereas in the second one it gets only those two back from the database in memory. That's what deferred execution means.

Andrei Cristof at Quora Visit the source

Was this solution helpful to you?

Other answers

This does not answer the IQueryable/Linq Provider for Entity Framework part but in general, Microsoft implements deferred execution in LINQ because it makes for a good business case. Here's how they do it.

Sathyaish Chakravarthy

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.