首页 新闻 搜索 专区 学院

求助, SQL转Linq

0
悬赏园豆:20 [已解决问题] 解决于 2011-12-04 01:55

SELECT
c.id,
c.CustomersName
as name,
f.FollowUpTheWay
as names,
f.NextFollowDate,
f.FollowDate,
f.id
as fid
from dbo.Slgl_CustomerReception as c
left join dbo.Slgl_FollowUpRecords as f on f.CustomersId = c.id and
f.id
= (select TOP(1) id from dbo.Slgl_FollowUpRecords where CustomersId = c.id and FollowDate <= '2011-7-20' order by id DESC)
where c.ProjectId = 9

如何转成linq 或 linq to ef 呢?

试了半天都不行

Y2zz的主页 Y2zz | 菜鸟二级 | 园豆:393
提问于:2011-07-22 22:01
< >
分享
最佳答案
0
var query=from c in db.Slgl_CustomerReception
join f
in db.slgl_FollowUpRecords on f.CustomersId equles c.id&&f.id==((from d in db.Slgl_FollowUpRecords where d.CustomersId==c.id&&d.FollowDate<='2011-7-20' orderbydescding d.id select d.id).firstofdefault()
)
where c.ProjectId==9

我没有测试,大概是这个意思

收获园豆:10
程序新青年 | 小虾三级 |园豆:841 | 2011-07-23 19:52
呵呵, 你这个不行
Y2zz | 园豆:393 (菜鸟二级) | 2011-07-26 15:00
其他回答(1)
0

这么复杂的sql 为什么要转呢?

收获园豆:10
LoveJenny | 园豆:532 (小虾三级) | 2011-07-26 19:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册