2013-10-30 165 views
0

我有一个SQL查询,我知道它按预期工作。但我需要它是我用来与数据库进行交互的LINQ。 SQL查询是:SQL到LINQ转换问题

SELECT * FROM motorposition, experimentmotor, motors 
WHERE motorposition.motorid = experimentmotor.motorid 
AND experimentmotor.experimentid = 13 
AND motors.id = experimentmotor.motorid 

我几乎没有使用LINQ的经验。 LINQ中甚至有可能这样做吗?

回答

0

的代码将是这样的:

var results = from mp in yourcontext.motorposition 
    join e in yourcontext.experimentmotor on mp.motorid equals e.motorid 
    join m in yourcontext.motors on e.motorid equals m.motorid 
    where e.experimentid == 13 
    select new {mp, e, m}; 
+0

谢谢你,帮了我很多:) – Diemauerdk