I am looking for a way to make GroupBy on a complex object, and not just on one property. The problem is that I want to do this on IQueryable , because getting all the data from the table in this case is a very bad idea.
We are using Entity Framework 6.1.
The class is as follows:
public class Pin {
public Guid Id {get;set;}
public Guid PageId {get;set;}
public PageClass Page {get;set;}
}
I need to report the time when a particular page was “pinned”, also printing the name of the page.
Now my code is as follows:
var pinnedPages = GetAll().GroupBy(x => x, comparer);
foreach (var pinnedPage in pinnedPages)
{
var numberOfTimesPinned = pinnedPage.Count();
var pin = pinnedPage.Key;
}
But if I group on the PageId page, it pinnedPage.Keyreturns Guid, obviously, while I need the whole object Pagefor my reporting needs.
, SQL, , .