diff --git a/Ctoss/Builders/Filters/FilterBuilder.cs b/Ctoss/Builders/Filters/FilterBuilder.cs index 942754a..7b6fa74 100644 --- a/Ctoss/Builders/Filters/FilterBuilder.cs +++ b/Ctoss/Builders/Filters/FilterBuilder.cs @@ -13,23 +13,20 @@ public class FilterBuilder private readonly IPropertyFilterBuilder _numberFilterBuilder = new NumberFilterBuilder(); private readonly IPropertyFilterBuilder _setFilterBuilder = new SetFilterBuilder(); - public Expression>? GetExpression(AgGridFilter? filterSet) + public Expression>? GetExpression(Dictionary? filterSet) { if (filterSet == null) return null; var expressions = new List>>(); - expressions.AddRange(filterSet.Filters + expressions.AddRange(filterSet .Select(filter => GetExpressionInternal(filter.Key, filter.Value))); return expressions.Aggregate((acc, expr) => acc.AndAlso(expr)); } public Expression>? GetExpression(string property, FilterModel filter) - => GetExpression(new AgGridFilter - { - Filters = new Dictionary { { property, filter } } - }); + => GetExpression(new Dictionary { { property, filter } }); private Expression> GetExpressionInternal(string property, FilterModel? filter) { diff --git a/Ctoss/Extensions/AgGridExtensions.cs b/Ctoss/Extensions/AgGridExtensions.cs index 832e37e..9c2a8b2 100644 --- a/Ctoss/Extensions/AgGridExtensions.cs +++ b/Ctoss/Extensions/AgGridExtensions.cs @@ -6,7 +6,7 @@ public static class AgGridExtensions { public static AgGridQueryResult Apply(this IEnumerable all, AgGridQuery query) { - var applyFilter = query.FilterModel!.Filters is { Count: > 0 }; + var applyFilter = query.FilterModel is { Count: > 0 }; if (applyFilter) all = all.WithFilter(query.FilterModel!); @@ -26,7 +26,7 @@ public static AgGridQueryResult Apply(this IEnumerable all, AgGridQuery public static AgGridQueryResult Apply(this IQueryable all, AgGridQuery query) { - var applyFilter = query.FilterModel!.Filters is { Count: > 0 }; + var applyFilter = query.FilterModel! is { Count: > 0 }; if (applyFilter) all = all.WithFilter(query.FilterModel!); diff --git a/Ctoss/Extensions/EnumerableExtensions.cs b/Ctoss/Extensions/EnumerableExtensions.cs index 1405eb7..339d315 100644 --- a/Ctoss/Extensions/EnumerableExtensions.cs +++ b/Ctoss/Extensions/EnumerableExtensions.cs @@ -71,7 +71,7 @@ public static IEnumerable WithSorting(this IEnumerable query, List WithFilter( this IEnumerable query, string jsonFilter) => query.WithFilter( - JsonSerializer.Deserialize( + JsonSerializer.Deserialize?>( jsonFilter, CtossJsonDefaults.DefaultJsonOptions) ); @@ -79,17 +79,12 @@ public static IEnumerable WithFilter( this IEnumerable query, string propertyName, FilterModel? filter) => filter is null ? query - : WithFilter( - query, - new AgGridFilter - { - Filters = new Dictionary { { propertyName, filter } } - }); + : WithFilter(query, new Dictionary { { propertyName, filter } }); public static IEnumerable WithFilter( - this IEnumerable query, AgGridFilter? filterSet) + this IEnumerable query, Dictionary? filterSet) { - if (filterSet is null || !filterSet.Filters.Any()) + if (filterSet is null || !filterSet.Any()) return query; var filterBuilder = new FilterBuilder(); diff --git a/Ctoss/Extensions/QueryableExtensions.cs b/Ctoss/Extensions/QueryableExtensions.cs index c332327..e143fed 100644 --- a/Ctoss/Extensions/QueryableExtensions.cs +++ b/Ctoss/Extensions/QueryableExtensions.cs @@ -71,7 +71,7 @@ public static IQueryable WithSorting(this IQueryable query, List WithFilter( this IQueryable query, string jsonFilter) => query.WithFilter( - JsonSerializer.Deserialize( + JsonSerializer.Deserialize?>( jsonFilter, CtossJsonDefaults.DefaultJsonOptions) ); @@ -79,17 +79,12 @@ public static IQueryable WithFilter( this IQueryable query, string propertyName, FilterModel? filter) => filter is null ? query - : WithFilter( - query, - new AgGridFilter - { - Filters = new Dictionary { { propertyName, filter } } - }); + : WithFilter(query, new Dictionary { { propertyName, filter } }); public static IQueryable WithFilter( - this IQueryable query, AgGridFilter? filtersSet) + this IQueryable query, Dictionary? filtersSet) { - if (filtersSet is null || !filtersSet.Filters.Any()) + if (filtersSet is null || !filtersSet.Any()) return query; var filterBuilder = new FilterBuilder(); diff --git a/Ctoss/Models/AgGrid/AgGridQuery.cs b/Ctoss/Models/AgGrid/AgGridQuery.cs index abe6e51..2f79f4f 100644 --- a/Ctoss/Models/AgGrid/AgGridQuery.cs +++ b/Ctoss/Models/AgGrid/AgGridQuery.cs @@ -6,5 +6,5 @@ public record AgGridQuery( int StartRow, int EndRow, List? SortModel, - AgGridFilter? FilterModel + Dictionary? FilterModel );