Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that IQueryable gets converted explicitly to IEnumerable #44

Open
pgrm opened this issue Mar 18, 2017 · 0 comments
Open

Check that IQueryable gets converted explicitly to IEnumerable #44

pgrm opened this issue Mar 18, 2017 · 0 comments

Comments

@pgrm
Copy link

pgrm commented Mar 18, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants