Relative Content

Tag Archive for linq

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?

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.

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.

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?