我想将下面的简单 SQL 查询更改为 LINQ,如何更改?
select * from table1 where isPaid = 'true' and Id in (select Id from table2 where EmployeeId = 12)
类似于这个?
from pa in db.PaymentAdvices
where pa.IsPaid == true
orderby pa.PaidDate descending
select pa;
我想将下面的简单 SQL 查询更改为 LINQ,如何更改?
select * from table1 where isPaid = 'true' and Id in (select Id from table2 where EmployeeId = 12)
类似于这个?
from pa in db.PaymentAdvices
where pa.IsPaid == true
orderby pa.PaidDate descending
select pa;
这里代码linq到sql:
from t1 in table1
join t2 in table2 on t1.Id equals t2.Id
where t2.EmployeeId = 12
select t1
希望有用!
如果字段isPaid的数据类型为Boolean:
from t1 in table1
join t2 in table2 on t1.Id equals t2.Id
where t2.EmployeeId = 12 and t1.isPaid == true
select t1
如果字段isPaid的数据类型为String:
from t1 in table1
join t2 in table2 on t1.Id equals t2.Id
where t2.EmployeeId = 12 and t1.isPaid.Equals("true")
select t1