You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We had an issue few weeks ago, where we a colleague was passing Func into the Where extension method of a DbSet object, thinking it would get executed on DB. But of course, Func is for IEnumerable and executed in memory. The fix was simple, since what he wrote in Func could just as well be written as Expression and that did the fix.
But relying on spotting such a mistake during code review seems quite dangerous, so if there would be an analyzer which checks, that as long as an object implements IQueryable you aren't allowed to use the IEnumerable extension methods. This way the switch to IEnumerable would be more explicit viaToList or ToArray
The text was updated successfully, but these errors were encountered:
We had an issue few weeks ago, where we a colleague was passing
Func
into theWhere
extension method of aDbSet
object, thinking it would get executed on DB. But of course,Func
is forIEnumerable
and executed in memory. The fix was simple, since what he wrote inFunc
could just as well be written asExpression
and that did the fix.But relying on spotting such a mistake during code review seems quite dangerous, so if there would be an analyzer which checks, that as long as an object implements
IQueryable
you aren't allowed to use theIEnumerable
extension methods. This way the switch toIEnumerable
would be more explicit viaToList
orToArray
The text was updated successfully, but these errors were encountered: