0
我的代码:动态where条件在LINQ查询表达式
IEnumerable<DataRow> whrRowEnum;
whrRowEnum = from r in dtInput.AsEnumerable()
where r.Field<string>("EMP_DEP") == "DEP1"
orderby EMP_DEP
select r;
上面的代码由于做工精细的硬编码在那里的条件,但在运行时我需要添加多个WHERE条件在我的LINQ查询像r.Field( “EMP_DEP”)== “DEP1” & & r.Field( “EMP_ID”)== “EMP1”
它应该是'(!condition1 || (...))&&(!condition2 ||(...))'或者当条件1或2为假时,where子句等于false。 – Matten
@Matten谢谢!固定 –