i hardly use EF so not string in it.
code taken from https://www.mikesdotnetting.com/article/257/entity-framework-recipe-grouping-by-year-and-month
public ActionResult Index()
{
var context = new EFRecipeContext();
var model = context.Orders
.GroupBy(o => new
{
Month = o.OrderDate.Month,
Year = o.OrderDate.Year
})
.Select(g => new ArchiveEntry
{
Month = g.Key.Month,
Year = g.Key.Year,
Total = g.Count()
})
.OrderByDescending(a => a.Year)
.ThenByDescending(a => a.Month)
.ToList();
return View(model);
}stuck to understand this area specially
.Select(g => new ArchiveEntry
{
Month = g.Key.Month,
Year = g.Key.Year,
Total = g.Count()
})why we need to select month like g.Key.Month ?
why can't we write g.Month ?
from where the key keyword comes in linq....it is never defined in code. help me to understand