Skip to content

Check that IQueryable gets converted explicitly to IEnumerable #44

@pgrm

Description

@pgrm

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions