C# 4.0 从sql语句到linq语句的转换
我怎么翻译C# 4.0 从sql语句到linq语句的转换,c#-4.0,C# 4.0,我怎么翻译 select * from employees where (emp_id=@emp or @emp is null) and (dep_id=@dep or @dep is null) 到LINQ Station?C# 我假设@emp为null部分是一个输入错误,并且您希望emp\u id为null。如果没有,就把它调换一下 我建议用LINQ。对不起,没有办法。LINQ提供程序的设计目的是获取代码并转换为SQL语句,而不是相反 int empID = [whatever...]
select * from employees where (emp_id=@emp or @emp is null) and (dep_id=@dep or @dep is null)
到LINQ Station?C#
我假设@emp为null
部分是一个输入错误,并且您希望emp\u id为null
。如果没有,就把它调换一下
我建议用LINQ。对不起,没有办法。LINQ提供程序的设计目的是获取代码并转换为SQL语句,而不是相反
int empID = [whatever...]
var e = from e in db.Employees
where e.emp_id == empID || e.emp_id == null
select e;