あなたは確かMin
に次の方法で拡張メソッドを使うことができます:
from item in collection where
(new[] { val1-val2, item.Property1, somethingElse }.Min()) > item.Property2
select item;
ただし、これにより、のそれぞれに対して新しい配列がインスタンス化されitem
ますcollection
。これは、パフォーマンスの面で最善のアプローチではない可能性があります。最小の3つの値を取得するための単純なメソッドを作成することをお勧めします。
public double Min(double a, double b, double c)
{
double result = a;
if (result < b)
{
result = b;
}
if (result < c)
{
result = c;
}
return result;
}
次に、次のクエリを記述できます。
from item in collection where
Min(val1-val2, item.Property1, somethingElse) > item.Property2
select item;