The entity or complex type ‘ ‘ cannot be constructed in a LINQ to Entities query [duplicate]

In Linq-to-Entities you can only project to an anonymous type or a regular class. You can’t project to an existing entity type. You can with linq-to-objects like so

var tasks = (from i in data.Incidents
            join a in data.Accounts on i.CustomerID equals a.Acct_CID
             select new
             {
               creator_id = a.ID,
               start_date = i.DateOpened,
               end_date = i.DateCLosed
              // ...
             }).AsEnumerable().Select(x => new Tasks {
               creator_id = x.creator_id,
               start_date = x.start_date,
               end_date = x.end_date              
             }).ToList();

Leave a Comment