0

我有一个 SQL 查询,我知道它按预期工作。但我需要它是用于与数据库交互的 LINQ。SQL查询是:

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

我几乎没有使用 LINQ 的经验。甚至可以在 LINQ 中执行此操作吗?

4

1 回答 1

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};
于 2013-10-30T14:53:50.877 回答