我有函数做动态 linq where to dbset on dbcontext 但得到错误 No method 'Where' exists on type System.Linq.IQueryable
I don't now!!!
using System.Linq;
public virtual Queryable _List(string fieldNames="", string values="")
{
_Db = Contex.Set<T>();
var type = typeof(T);
var property = type.GetProperty(fieldNames);
var parameter = Expression.Parameter(type, "p");
var propertyAccess = Expression.MakeMemberAccess(parameter, property);
var orderByExp = Expression.Lambda(propertyAccess, parameter);
var body2 = Expression.Call(
typeof(Queryable),
"Where",
// I things this line no good but I don't now ...
new Type[] { type, property.PropertyType },
_Db.Expression,
Expression.Quote(orderByExp));
var m = _Db.Provider.CreateQuery<T>(body2);
return m;
}