НС>НС>ints.Where(x => MyMethod(x, c1, c2) || (x > c3 && x < c4));
НС>[ExpressionMethod("MyMethodExpr")]
НС>private static bool MyMethod(int x, int c1, int c2)
НС>{
НС> return (x > c1 && x < c2);
НС>}
НС>private static Expression<Func<int, int, int, bool>> MyMethodExpr()
НС>{
НС> return (x, c1, c2) => x > c1 && x < c2;
НС>}
НС>
Теперь введем естественное усложнение тестовой задачи:
IEnumerable<int> ints = ...;
ints.Where(x => MyMethod(x, c1, c2, myEnum) || (x > c3 && x < c4));
private static bool MyMethod(int x, int c1, int c2, MyEnum myEnum)
{
switch (myEnum)
{
case MyEnum.Item1:
return x > c1 && x < c2;
case MyEnum.Item2:
return x > c1 && x < c2*c1;
case MyEnum.Item3:
return x > c1 && x < c2%c1*17;
default:
throw new ArgumentOutOfRangeException("myEnum");
}
}
Покажи свои "развитые" средства декомпозиции для IQueryable<T>.
P.S. в моем подходе это реализуется естественным образом