I have a list of items, I want ,via expression, to filter out the items using my own custom function.
Something like this
return Items.Where(Foo)
private static bool Foo(Item item) { item.Name.Equals("...");
what i currently have
public static Expression BuildExpression(IList<Item> items)
{
Expression<Func<Item, bool>> expression = item => Foo(item);
var method = (expression.Body as MethodCallExpression)?.Method;
return Expression.Call(method, Expression.Constant(items.First());
}
this seems to work find and well for 1 item but i can't figure out how to change it to work for IList<Item>
P.s
Foo signature can be changed if needed
In the nutshell you need to find the
Enumerable.Where<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)method. For example:[email protected]
[email protected] with .NET Framework 4.7.1, main change:
P.S.
TBH I doubt that this would be very useful for you but without having full overview of the problem it is hard to tell.