Nesting Linq-to-Objects query within Linq-to-Entities query –what is happening under the covers?
var numbers = new int[] { 1, 2, 3, 4, 5 }; var contacts = from c in context.Contacts where c.ContactID == numbers.Max() | c.ContactID == numbers.FirstOrDefault() select c; foreach (var item in contacts) Console.WriteLine(item.ContactID); Linq-to-Entities query is first translated into Linq expression tree, which is then converted by Object Services into command tree. And […]
Using ‘new’ in a projection?
I wish to project a collection from one type (Something
) to another type (SomethingElse
). Yes, this is a very open-eneded question, but which of the two options below do you prefer?
Algorithm to optimize grouping
I would like to know if there’s a known algorithm or best practice way to do the following:
for vs. foreach vs. LINQ
When I write code in Visual Studio, ReSharper (God bless it!) often suggests me to change my old-school for loop in the more compact foreach form.
Is it better to create a stored procedure or entities to get to the data I need?
I just jumped into a new project with a new company using Entity Framework and ASP.NET MVC 4. I am no expert on Entity Framework, but I think I have a decent grasp of how to use it.
What problem domain is LINQ made for?
Each time I see a question posted on Stack Overflow on C#, I see at least one or two answers posted that solve a problem with LINQ. Usually people with very high reputation seem to use LINQ like pros.
Style for creating IEnumerable unions [closed]
Closed 9 years ago.
Is it okay to convert dataset from stored procedure to IEnumerable
So, I am working on a project with a team and we are using Entity Framework. We basically want to use linq to entities, and not use stored procedures. I use quite a bit of lists and IEnumerables and so does everyone else.
Why should IQueryProvider implementations throw NotSupportedExceptions?
Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don’t actually support the full IQueryable<T>
interface, throwing NotSupportedExceptions
when they encounter something they don’t like, such as LinqToSql and SkipWhile
. My question is this: why do ORM providers opt to throw a NotSupportedException
instead of letting certain query operators (that do not translate well or at all to the target data source) trip a query execution and then let Linq to objects handle the rest?
Why should IQueryProvider implementations throw NotSupportedExceptions?
Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don’t actually support the full IQueryable<T>
interface, throwing NotSupportedExceptions
when they encounter something they don’t like, such as LinqToSql and SkipWhile
. My question is this: why do ORM providers opt to throw a NotSupportedException
instead of letting certain query operators (that do not translate well or at all to the target data source) trip a query execution and then let Linq to objects handle the rest?