日期:2014-05-20  浏览次数:20827 次

linq 左连接怎么改
            var Query = (from adviceNoteInstance in adviceNoteEarnestMoneyTableEntities.AdviceNoteEarnestMoneyInstance.Where(a => a.AdviceID == AdvID && (a.AdviceState != 40 || a.UserName == "-"))
                         select new
                         {
                             adviceNoteInstance.InstanceID,
                             adviceNoteInstance.AdviceID,
                             adviceNoteInstance.AdviceState,
                             adviceNoteInstance.FState,
                             adviceNoteInstance.UserName,
                             adviceNoteInstance.CreateTime,
                             adviceNoteInstance.FinishedTime,
                             MaxInstanceID = adviceNoteEarnestMoneyTableEntities.AdviceNoteEarnestMoneyInstance.Where(a => a.AdviceID == AdvID && (a.AdviceState != 40 || a.UserName == "-")).Max(a => a.InstanceID)
                         }).OrderBy(a => a.InstanceID);

dbo.AdviceNoteTable 左联接上面的主表   (adviceNoteInstance.AdviceID 关联字段
)  怎么改  我不会lambda的写法 

------解决方案--------------------
var Query = (from adviceNoteInstance in adviceNoteEarnestMoneyTableEntities.AdviceNoteEarnestMoneyInstance.Where(a => a.AdviceID == AdvID && (a.AdviceState != 40 
------解决方案--------------------
 a.UserName == "-"))
                     join adviceNodeTable in AdviceNoteTable
                     on adviceNoteInstance.AdviceID equals adviceNodeTable.AdviceID into joinAdviceNoteTableEmp
                     from advice in joinAdviceNoteTableEmp.DefaultIfEmpty()