我试图在两个表之间进行左连接并在运行时获得跟随错误
错误消息 - 无法在LINQ to Entities查询中构造实体或复杂类型“XactETLModel.XactETL_ShredQueue_Exceptions”。
var query = (from a in xactCtxt.dctShredCompletes
join b in xactCtxt.XactETL_ShredQueue_Exceptions on a.QueueID equals b.QueueID
into c
from d in c.DefaultIfEmpty( new XactETL_ShredQueue_Exceptions() )
where a.ShredCompleteDate >= startDate && a.ShredCompleteDate <= endDate
select new { a.QueueID , a.ShredMode ,a.ShredCompleteDate , d.ExceptionDate ,d.ErrorMessage }).ToList();
答案 0 :(得分:0)
以下代码修复了该问题。无需将右侧表作为类
传递var query = (from a in xactCtxt.dctShredCompletes
join b in xactCtxt.XactETL_ShredQueue_Exceptions on a.QueueID equals b.QueueID
into c
from d in c.DefaultIfEmpty( )
where a.ShredCompleteDate >= startDate && a.ShredCompleteDate <= endDate
select new { a.QueueID , a.ShredMode ,a.ShredCompleteDate , d.ExceptionDate ,d.ErrorMessage }).ToList();