我有一个场景,我必须在 LINQ 中使用动态 where 条件。
我想要这样的东西:
public void test(bool flag)
{
from e in employee
where e.Field<string>("EmployeeName") == "Jhom"
If (flag == true)
{
e.Field<string>("EmployeeDepartment") == "IT"
}
select e.Field<string>("EmployeeID")
}
我知道我们不能在 Linq 查询中间使用“If”,但解决方案是什么?
请帮忙...