I'm using an OnRead grid with ExpandoObjects. The error happens on the backend when trying to process the result of ToDataSourceResult(...)
When trying to access the Items property of AggregateFunctionsGroup in a multi level grouping scenario, using ExpandoObject, and the top level group has a null key, trying to access the Items property will result in a NullReferenceException. I've made this helper, but it cannot process the subgroups because of this error.
private static void FlattenGroup<T>(AggregateFunctionsGroup group, List<T> result)
{
if (group == null)
{
return;
}
if (group.HasSubgroups)
{
foreach (var sub in group.Items.OfType<AggregateFunctionsGroup>())
{
FlattenGroup(sub, result);
}
}
else
{
result.AddRange(group.Items.OfType<T>());
}
}
In a scenario where I have an ExpandoObject with properties A and B, where A = 1 and B = null; grouping by A then B works. Grouping by A or B alone also works. But grouping by B then A causes the NullReferenceException when trying to access the group.Items.