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
We had an issue few weeks ago, where we a colleague was passing
Funcinto theWhereextension method of aDbSetobject, thinking it would get executed on DB. But of course,Funcis forIEnumerableand executed in memory. The fix was simple, since what he wrote inFunccould just as well be written asExpressionand 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
IQueryableyou aren't allowed to use theIEnumerableextension methods. This way the switch toIEnumerablewould be more explicit viaToListorToArray