请帮助左加入Linq [英] Please help in Left Join Linq
本文介绍了请帮助左加入Linq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它给我一个错误,因为对象没有设置为对象的实例
It giving me Error as Object is not set to instance of object
var query = (from attendace in ListAttendace_Details
join makeup in ListMakeup
on attendace.Attendace_ID equals makeup.Attendace_ID
into yG
from y1 in yG.DefaultIfEmpty()
select new { Makup=y1.Attendace_ID==null?0:1,attendace.Status, attendace.ISAttend, attendace.Attendace_ID }).ToList();
推荐答案
我相信你在选择行上有例外。这些其他映射表中可能没有映射记录。哪个将返回null并且null不能被指定为选择结果,这将导致抛出您正在拥有的异常。所以尝试对你在Makup上做的其他选择字段进行空检查。
祝你好运,
OI
I believe you are having your exception on the select line. It is possible that, there is no mapping record present in these other mapping table. Which will return null and null cannot be assigned as select result and this will result in throwing the exception you are having. So try doing the null check to the other select fields you did on the Makup.
Good luck,
OI
这篇关于请帮助左加入Linq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文