我们可以在 linq 查询中动态附加 where 条件吗?
例如:
class Result
{
string v1;
string v2;
string v3;
}
List<Result> result = (from r in results select r);
//i want to do something like the following....
if(conditionA)
{
result = result appened (or v1 = xxx)
}
else if(conditionB)
{
result = result appened (or v2 = xxx)
}
else if(conditionC)
{
result = result appened (or v3 == xxx)
}
有人知道如何处理 Linq 中的条件吗????
日
最佳答案
如果你想动态构建它,你可以使用 PredicateBuilder
关于c# - 如何使用where条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2330722/