1
我收到以下錯誤,當我最終嘗試運行的查詢類型的Expression.IsFalse是未知的?
未知LINQ表達式「IsFalse」
這是代碼
private static IQueryable<T> QueryMethod<T>(
IQueryable<T> query,
QueryableRequestMessage.WhereClause.Rule rule,
Type type,
string methodName,
Expression property,
Expression value,
string op,
ParameterExpression parameter
) where T : class
{
var methodInfo = type.GetMethod(methodName, new[] { type });
var call = Expression.Call(property, methodInfo, value);
var expression = rule.Op.Equals(op)
? Expression.Lambda<Func<T, bool>>(call, parameter)
: Expression.Lambda<Func<T, bool>>(Expression.IsFalse(call), parameter);
query = query.Where(expression);
return query;
}
的重要變量有以下值
query: an IQueryable that I am building up
type: String
methodName: "EndsWith"
rule.Op: "ne" //Not Ends With
op: "ew"
value: "somestring"
基本上,如果op和rule.Op相等,它只是運行methodName(EndsWith)並相應地進行過濾。但是,如果它們不同,我想否定結果。
的Microsoft SQL Server 2008(SP3) – CaffGeek 2013-02-12 15:19:38
@CaffGeek:這不是LINQ提供程序。提供者是Linq to Entities,Linq to SQL等等。 – Jon 2013-02-12 15:20:37
比較虛假的作品,謝謝。 – CaffGeek 2013-02-12 15:24:59