本文介绍了实体或复杂类型''不能在LINQ to Entities查询中构造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在两个表之间进行左连接,并在运行时出现以下错误
I am trying to do left join between two tables and getting following error at runtime
错误消息-实体或复杂类型'XactETLModel.XactETL_ShredQueue_Exceptions'不能在LINQ to Entities查询中构造.
Error Message - The entity or complex type 'XactETLModel.XactETL_ShredQueue_Exceptions' cannot be constructed in a LINQ to Entities query.
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();推荐答案
以下代码解决了该问题.无需将右侧表作为类传递
Following code fix the issue. No need to pass the right side table as class
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();更多推荐
实体或复杂类型''不能在LINQ to Entities查询中构造
发布评论