I am trying to create a list of POCOs from my database. The POCO class has a List<int>
property which I want to populate like so:
public List<Pocos.MyTable> GetData()
{
using (EFContext c = new EFContext())
{
var query = from t in c.MyTable
select new Pocos.MyTable()
{
MyId = t.MyId,
MyField = t.MyField,
MyRelationIds = t.MyRelations.Select(mr => mr.MyRelationId).ToList()
};
return query.ToList();
}
}
Unfortunately I am getting the "this method cannot be translated into a store expression" on the ToList()
in the query. Can I do this nicely here, or do I have to do lots of subsequent queries to populate the MyRelationIds
property?