I'm building up a Linq.Expressions.Expression at runtime and then I thought I would use it like so:
Type myTypeVariable = viewModel.typeVariable;
DbContext db = //get entity model for myTypeVariable
Expression myExpression = //build a predicate of myTypeVariable from viewModel
var query = (IQueryable<myType>)db.Set(myTypeVariable);
var results = query.Provider.CreateQuery(myExpression);
The error I'm getting is at the .CreateQuery() stage: "Linq to Entities query expresions can only be constructed from instances that implement the IQueryable interface."
My confusion comes from the fact that if the last line it replaced with this I get results?: results = query.Where(c=>c.ID>0).ToList();
I've mostly been following this: https://msdn.microsoft.com/en-us/library/bb882637.aspx
How do I get results from my DbSet using my Expression predicate?