如何在MVC中实现SQL语句到LINQ



我需要将以下SQL解释为LINQ。

select 
t1.req_no,
t1.seq_no,
t1.quantity,
t1.uom,
t1.item_name,
t2.event_date 
from tb_cs_test t1, tb_cs_test2 t2 where (t1.req_no = 1 and t2.req_no = 1 );

我使用MVC,通过这个SQL语句,我需要根据我放置的条件抛出请求的字段

感谢

您可以使用JOIN:

from t1 in tb_cs_test 
join t2 in tb_cs_test2 
on t1.req_no equals t2.req_no
where t1.req_no = 1
select new {
t1.req_no,
t1.seq_no,
t1.quantity,
t1.uom,
t1.item_name,
t2.event_date 
}

最新更新