Since you're using Linq-to-Objects, that's simple enough to do:
IEnumerable<SignInReportGrouping> SignInData = SignInReports
.GroupBy(u => u.UserName)
.Select(user => new SignInReportGrouping
{
UserName = user.Key,
SignInReportDay = user
.GroupBy(u => u.EventTime.Date)
.Select(day => new SignInReportDay
{
Day = day.Key,
SignInReports = day.ToList(),
})
.ToList(),
})
.ToList();
You'll probably want to add the Day property to your SignInReportDay class so you know which day it represents:
public class SignInReportDay
{
public DateTime Day { get; set; }
public IEnumerable<SignInReport> SignInReports { get; set; }
}
NB: If you're using Entity Framework 6, you probably won't be able to use the .Date property. For EF6, use DbFunctions.TruncateTime:
.GroupBy(u => DbFunctions.TruncateTime(u.EventTime))
For EF Core, the .Date property should work correctly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer