为什么下面的代码会抛出 '... has some invalid arguments at'
var qry = listFoo.Where(lambda);
我应该如何编写我的 listFoo 以便通过传递谓词委托来调用 Where 。我的整个代码如下,
List<Foo> listFoo = new List<Foo>();
ParameterExpression foo = Expression.Parameter(typeof(Foo), "foo");
MemberExpression bar = Expression.PropertyOrField(foo, "Bar");
ConstantExpression abc = Expression.Constant("abc", typeof(string));
BinaryExpression test = Expression.Equal(bar, abc);
Expression<Func<Foo, bool>> lambda = Expression.Lambda<Func<Foo, bool>>(test, foo);
var qry = listFoo.Where(lambda);