我有一个SQL查询,我知道它可以按预期工作。但我需要它是LINQ,我用它来与数据库进行交互。 SQL查询是:
SELECT * FROM motorposition, experimentmotor, motors
WHERE motorposition.motorid = experimentmotor.motorid
AND experimentmotor.experimentid = 13
AND motors.id = experimentmotor.motorid
我几乎没有使用LINQ的经验。甚至可以在LINQ中执行此操作吗?
答案 0 :(得分: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};