1
votes

I am trying to do left join between two tables and getting following error at runtime

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();
1

1 Answers

0
votes

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();