I am getting a result set from a linq query and then using group by to group on two fields:
var dataElements = dataElements.GetAll();
var dataItems = dataElements.Where(el => el.Field1 == "DATE")
.GroupBy(x => new { x.Field2, x.Field3})
.ToList();
//why can't I do this:
foreach (var element in dataItems)
{
Console.WriteLine(element.Field2)
}
I get the following error:
Severity Code Description Project File Line Suppression State Error CS1061 'IGrouping<, dataElements>' does not contain a definition for 'Field2' and no accessible extension method 'Field2' accepting a first argument of type 'IGrouping<, dataElements>' could be found (are you missing a using directive or an assembly reference?) App.Program C:.....cs 498 Active