Search code examples
linqentity-framework

Ambiguous Invocation IQueryable or IEnumerable


I instantiated a context and want to write a simple query:

var result = db.Set.Where(x => x.Id == num).Select(whatever);

and I can't get rid of the red squiggly under Where complaining about an ambiguous invocation between System.Collections.Generic.IEnumerable and System.Linq.IQueryable. System.Linq is specifically referenced, and System.Collections.Generic is not referenced anywhere in the project. How can I tell the code that I want to use System.Linq.IQueryable?


Solution

  • Got it. People don't seem to like this answer, but it solved the problem I described in the question.

    db.Set.AsQueryable().Where(...