I'm new to Linq to Entity stuff, so I don't know if what I'm doing is the best approach.
When I do a query like this it compiles, but throws an error that it doesn't recognize the method GetItemSummaries. Looking it up, this seems to be because it doesn't like a custom method inside the query.
return (from c in _entity.Category
from i in c.Items
orderby c.Id, i.Id descending
select new CategoryDto
{
Id = c.Id,
Name = c.Name,
Items = GetItemSummaries(c)
}).ToList();
private IEnumerable<ItemSummary> GetItemSummaries(CategoryDto c)
{
return (from i in c.Items
select new ItemSummary
{
// Assignment stuff
}).ToList();
}
How would I combine this into a single query since I can't call a custom method?
I tried just replacing the method call with the actual query, but then that complains that ItemSummary isn't recognized instead of complaining that the method name isn't recognized. Is there any way to do this? (Or a better way?)