[HxGrid] - Using IQueryable + Formating String? Leads to Error #865
Replies: 3 comments 1 reply
-
@jirikanda, please take a look at this. |
Beta Was this translation helpful? Give feedback.
-
As a solution for EF Core the The change in The solution for the public static IQueryable<TItem> ApplyGridDataProviderRequest<TItem>(this IQueryable<TItem> source, GridDataProviderRequest<TItem> gridDataProviderRequest)
{
Expression<Func<TItem, IComparable>> RemoveConvertFromSortKeySelector(Expression<Func<TItem, IComparable>> sortKeySelectorExpressionLambda) => Expression.Lambda<Func<TItem, IComparable>>(sortKeySelectorExpressionLambda.Body.RemoveConvert(), sortKeySelectorExpressionLambda.Parameters[0]);
gridDataProviderRequest.CancellationToken.ThrowIfCancellationRequested();
// Sorting
if ((gridDataProviderRequest.Sorting != null) && gridDataProviderRequest.Sorting.Any())
{
Contract.Assert(gridDataProviderRequest.Sorting.All(item => item.SortKeySelector != null), $"All sorting items must have the {nameof(SortingItem<TItem>.SortKeySelector)} property set.");
IOrderedQueryable<TItem> orderedDataProvider = (gridDataProviderRequest.Sorting[0].SortDirection == SortDirection.Ascending)
? source.OrderBy(RemoveConvertFromSortKeySelector(gridDataProviderRequest.Sorting[0].SortKeySelector))
: source.OrderByDescending(RemoveConvertFromSortKeySelector(gridDataProviderRequest.Sorting[0].SortKeySelector));
for (int i = 1; i < gridDataProviderRequest.Sorting.Count; i++)
{
orderedDataProvider = (gridDataProviderRequest.Sorting[i].SortDirection == SortDirection.Ascending)
? orderedDataProvider.ThenBy(RemoveConvertFromSortKeySelector(gridDataProviderRequest.Sorting[i].SortKeySelector))
: orderedDataProvider.ThenByDescending(RemoveConvertFromSortKeySelector(gridDataProviderRequest.Sorting[i].SortKeySelector));
}
source = orderedDataProvider;
}
// Paging / Infinite scroll
if (gridDataProviderRequest.StartIndex > 0)
{
source = source.Skip(gridDataProviderRequest.StartIndex);
}
if (gridDataProviderRequest.Count > 0)
{
source = source.Take(gridDataProviderRequest.Count.Value);
}
return source;
}
} |
Beta Was this translation helpful? Give feedback.
-
Continues as issue #883. |
Beta Was this translation helpful? Give feedback.
-
Hi
I took the example that was on the demo page https://havit.blazor.eu/components/HxGrid#IQueryable and I changed it to EF Core instead of the memory DTO that the example uses, but I run into this
Beta Was this translation helpful? Give feedback.
All reactions