私は現在LambdaExpresionを持っています:http://pastebin.com/ZGCiQdHe
そして、53行目http://msdn.microsoft.com/en-us/library/bb340145(v=vs.90).aspxでArgumentExceptionが発生します
var lExpresion = Expression.Lambda<Func<TEntity, bool>>(body, parametrsNumber, parametrsTyp, parametrsLp);
しかし、私は自分が何を間違えているのか理解していません。
私は手に入れたい:
WHERE ((twr_gidnumer =1 and twr_gidtyp = 1 and twr_gidlp = 1) OR
(twr_gidnumer =1 and twr_gidtyp = 1 and twr_gidlp = 2))
--ANSWERR FULL
記事に基づく:
http://blogs.msdn.com/b/mattwar/archive/2007/07/31/linq-building-an-iqueryable-provider-part-ii.aspxhttps://stackoverflow.com/2 引数のラムダ式の変換1つの引数にラムダ式
public static Expression<Func<CDNXL_TwrKarty, bool>> Bind2nd(Expression<Func<CDNXL_TwrKarty, CDNXL_TwrKarty,CDNXL_TwrKarty, bool>> source)
{
Expression newBody = new Rewriter(source.Parameters[0]).Visit(source.Body);
return Expression.Lambda<Func<CDNXL_TwrKarty, bool>>(newBody, source.Parameters[0]);
}
internal class Rewriter : ExpressionVisitor
{
private readonly ParameterExpression candidate_;
public Rewriter(ParameterExpression candidate)
{
candidate_ = candidate;
}
protected override Expression VisitParameter(ParameterExpression p)
{
return candidate_;
}
}
//REPLACE EXECUTING PLACE
var retMultiLamnda = Expression.Lambda<Func<CDNXL_TwrKarty, CDNXL_TwrKarty, CDNXL_TwrKarty, bool>>(body, parametrsNumber, parametrsTyp, parametrsLp);
var retOneLambda = Bind2nd(retMultiLamnda);
var retQuery = query.Where(retOneLambda);
return retQuery;
ヘルプをありがとうRafal。