首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

SQL 改成用 Linq 实现。该怎么解决

2012-02-28 
SQL 改成用 Linq 实现。SELECTc.id,c.CustomersName as name,f.FollowUpTheWay as names,f.NextFollowDate,

SQL 改成用 Linq 实现。
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
leftjoindbo.Slgl_FollowUpRecords as f on 
f.id=(select TOP(1)id from dbo.Slgl_FollowUpRecords where CustomersId=c.idandFollowDate<='2011-7-20' order by id DESC)
where c.ProjectId= 9
linq句关键点请帮忙注释下,谢谢。

[解决办法]
小菜。。。
等着。。。。

C# code
var query=from c in dbo.Slgl_CustomerReception          where c.ProjectId==9          let temp= dbo.Slgl_FollowUpRecords.Where(t=>t.CustomersId==c.id && t.FollowDate <= Convert.ToDateTime("2011-7-20")).OrderByDescending(t=>t.id).FirstOrDefault().id          join f in dbo.Slgl_FollowUpRecords          on f.id equals temp into g          from f in g.DefaultIfEmpty()          select new            {        id=c.id,                name=c.CustomersName ,                names=f==null?"":f.FollowUpTheWay,                NextFollowDate=f==null?"":f.NextFollowDate,        FollowDate=f==null?"":f.FollowDate,                fid=f==null?"":f.id            }
[解决办法]
探讨
小菜。。。
等着。。。。

C# code

var query=from c in dbo.Slgl_CustomerReception
where c.ProjectId==9
let temp= dbo.Slgl_FollowUpRecords.Where(t=>t.CustomersId==c.id &amp;&amp; t.Follo……

[解决办法]
探讨

引用:
小菜。。。
等着。。。。

C# code

var query=from c in dbo.Slgl_CustomerReception
where c.ProjectId==9
let temp= dbo.Slgl_FollowUpRecords.Where(t=>t.CustomersId==c.id &amp;amp;&amp……

热点排行