I have this complex model:
public class complexModel
{
public aTable aObject { get; set; }
public List<bTable> bObjectList { get; set; }
public List<cTable> cObjectList { get; set; }
}
Then in the controller, I declare this object:
var AAA = new complexModel();
Now this code works fine
AAA.bObjectList= (from tdrc in db.bTable
select new bTable
{
ID = tdrc.ID ,
bName = tdrc.bName,,
}).ToList();
but when I write this
AAA.cObjectList= (from tdrc in db.cTable
where tdrc.cID == id
select new cTable
{
cID = tdrc.cID,
cName = tdrc.cName,
}).ToList();
I get this error:
System.NotSupportedException: 'The entity or complex type 'Project.DAC.cTable' cannot be constructed in a LINQ to Entities query.'