Hi,
I have problem when I use aggregates on included fields in EF Core. Let me try to explain:
I have following queriable data:
IQueryable<TblCarrier> queriableData = context.TblCarriers
.Include(x => x.CarPosU)
.Include(x => x.CarPosToNavigation)
.Include(x => x.CarArtU)
.AsQueryable();
The code herunder is working fine:
<GridAggregates>
<GridAggregate Field="CarArtUid" Aggregate="@GridAggregateType.Count" />
</GridAggregates>
<GridColumns>
<GridColumn Field="CarUid" FieldType="@(typeof(long))" Title="Uid" Width="150" Editable="false" Filterable="true">
</GridColumn>
<GridColumn Field="CarBarcode" FieldType="@(typeof(long))" Title="Barcode" Width="150" Editable="false" Filterable="true"/>
<GridColumn Field="CarTsCreation" FieldType="@(typeof(DateTime))" Title="Ts Created" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
<GridColumn Field="CarTsLastMove" FieldType="@(typeof(DateTime))" Title="Ts Moved" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
<GridColumn Field="CarDescription" FieldType="@(typeof(string))" Title="Description" Width="200" Editable="@(this.RoleLevel>=eRoles.Administrator)" Filterable="true"/>
<GridColumn Field="CarArtUid" FieldType="@(typeof(long))" Title="Article" Width="200" Editable="@(this.RoleLevel>=eRoles.Developer)" Filterable="true">
<GroupHeaderTemplate>
Count: (@context.Count)
</GroupHeaderTemplate>
</GridColumn>
But when I try this, The context.count value is null:
<GridAggregates>
<GridAggregate Field="CarArtU.ArtErpCode" Aggregate="@GridAggregateType.Count" />
</GridAggregates>
<GridColumns>
<GridColumn Field="CarUid" FieldType="@(typeof(long))" Title="Uid" Width="150" Editable="false" Filterable="true">
</GridColumn>
<GridColumn Field="CarBarcode" FieldType="@(typeof(long))" Title="Barcode" Width="150" Editable="false" Filterable="true"/>
<GridColumn Field="CarTsCreation" FieldType="@(typeof(DateTime))" Title="Ts Created" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
<GridColumn Field="CarTsLastMove" FieldType="@(typeof(DateTime))" Title="Ts Moved" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
<GridColumn Field="CarDescription" FieldType="@(typeof(string))" Title="Description" Width="200" Editable="@(this.RoleLevel>=eRoles.Administrator)" Filterable="true"/>
<GridColumn Field="CarArtU.ArtErpCode" FieldType="@(typeof(long))" Title="Article" Width="200" Editable="@(this.RoleLevel>=eRoles.Developer)" Filterable="true">
<GroupHeaderTemplate>
Count: (@context.Count)
</GroupHeaderTemplate>
</GridColumn>
The griddata is refreshed with the onread event
DataEnvelope<T> dataToReturn = null;
if (_Request.Groups.Count > 0)
{
// Group again => Do grouping on local data
if (Result.Data != null)
{
Result = await Result.Data.ToDataSourceResultAsync(_Request);
dataToReturn = new DataEnvelope<T>
{
GroupedData = Result.Data.Cast<AggregateFunctionsGroup>().ToList(),
TotalItemCount = Result.Total
};
_GridData = dataToReturn.GroupedData.Cast<object>().ToList();
}
}
else
{
dataToReturn = new DataEnvelope<T>
{
CurrentPageData = Result.Data.Cast<T>().ToList(),
TotalItemCount = Result.Total
};
_GridData = dataToReturn.CurrentPageData.Cast<object>().ToList();
}
The grouped data seems to be fine. (See attached screenshot). The aggregate items key is CarArtU-ArtErpCode. Shouldn't that be CarArtU.ArtErpCode?
Thanks