2

dbcontext で dbset を実行する動的 linq 関数を持っていますが、No method 'Where' exists on type というエラーが発生しますSystem.Linq.IQueryable

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;
}
4

1 に答える 1