我对某些" OR"进行了查询。运营商。例如。
entities.Where(e=> (...) || (...) || (...) || (...));
我想将此分解为几个调用,例如Where()
函数允许我。例如:
entities = entities.Where(e => (some logic A));
// ...
entities = entities.Where(e => (some logic B));
// ...
entities = entities.Where(e => (some logic C));
可以使用OR
逻辑代替AND
逻辑吗?
我想将此逻辑分解为几行代码的主要原因是每个OR
可以由不同的函数应用。
答案 0 :(得分:2)
你可以这样做:
set1 = entities.Where(e => (some logic A));
set2 = entities.Where(e => (some logic B));
set3 = entities.Where(e => (some logic C));
entities = set1.Union(set2).Union(set3);