关于C# LINQ查询的问题

2025-05-10 00:03:45
推荐回答(1个)
回答1:

var query = from x in table
where a1 != 0 ? x.a1 == a1 : (a2 != 0 ? x.a2 == a2 : (a3 != 0 ? x.a1 == a3 : true))
select x;
或者
var query = from x in table
where (a1 != 0 ? x.a1 == a1 : true) && (a2 != 0 ? x.a2 == a2 : true) && (a3 != 0 ? x.a1 == a3 : true)
select x;