Reputation: 8351
How can I get a count by Month from the Linq query below? An error is returned telling me that "grp.INPUT_SOURCE" doesn't exist.
var yesterday = DateTime.Today.AddDays(-365);
var Total = UPDATE_TRANSACTIONS
.Where(m => m.CREATE_DATE > yesterday)
.Where(m => m.CREATE_DATE < DateTime.Today)
.GroupBy(m=> new{m.CREATE_DATE.Value.Year, m.CREATE_DATE.Value.Month,m.CREATE_DATE.Value.Day, m.INPUT_SOURCE})
.Select(grp => new {
source = grp.INPUT_SOURCE,
Count = grp.Count()
});
Total.Dump();
Upvotes: 0
Views: 69
Reputation: 13409
It should be source = grp.Key.INPUT_SOURCE,
since that column is part of the Key
Upvotes: 4