I want to group by a list of objects inherited from an abstract class by:
- Type of item in list (in this example MyAction or MyObservation)
- An integer attribute ClassId
- A string attribute Value
And get a count out those groups.
public abstract class MyData
{
public int ClassId;
public string Value;
//...
}
public class MyAction : MyData
{
//...
}
public class MyObservation : MyData
{
//...
}
// in some class...
IEnumerable<MyData> _myDatas;
void TryGroupBy()
{
var result = _myDatas.GroupBy(
data => KeySelector(data), /* ?? key is 3 pieces of info */,
data => ElementSelector/* ?? I didn't get this either */,
(row, rows) => new
{
ClassId = ?? /*how to get it from 3 piece key */
TypeOfObject = /* how to get it ?? */
Value = /* how to get it ?? */
Count = rows.Count
}));