I am trying to get the last content of each type, currently I am using something similar to the following code to extract n records for each type
int n = 10;
var contents = Entities.OrderByDescending(i => i.Date);
IQueryable<Content> query = null;
for (int i = 1; i<=5; i++)
{
if (query == null)
{
query = contents.Where(c => c.ContentTypeIndex == i).Take(n);
}
else
{
query = query.Concat(contents.Where(c => c.ContentTypeIndex == i).Take(n));
}
}
Another solution could be to create an SP, but is it possible by grouping in EF? If not, is there any cleaning solution?
source
share