实体或复杂类型''不能在LINQ to Entities查询中构造

编程入门 行业动态 更新时间:2024-10-12 22:28:52
本文介绍了实体或复杂类型''不能在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查询中构造

本文发布于:2023-11-16 15:24:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:能在   实体   类型   LINQ   Entities

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!