I’m trying to shape results into “FullList” this using VS2012 & EF5:
public class FullList {
public int ListID {get; set;}
public string ListName {get; set;}
public List<ListItems> ListItems {get; set;}
}
public class ListItems {
public int ItemID {get; set;}
public string ItemName {get; set;}
}
And here is my query that is generating the annoying error of “LINQ to Entities does not recognize the method…blahblahblah….. and this method cannot be translated into a store expression.”
List<FullList> x = (from l in entities.Lists
select new FullList
{
ListID = l.ListID,
ListName = l.ListName,
ListItems = l.ListItems.Select(li => new ListItems
{
ItemID = li.ItemID,
ItemName = li.ItemName
}).ToList()
}).ToList();
It compiles fine and, to me, it looks like it should work, but no dice… Any ideas?
thanks in advance
Unfortunately, the EF does not support you modify the values in the scope of the block select. So you could create your query, executes it and get the results in list format of the mapped object and after that perform the conversion to your ViewModel, DTO etc … Try something like this: