日期:2014-05-20 浏览次数:20983 次
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
            }
------解决方案--------------------