Class EntityFilterBuilder
- Namespace
- Arbiter.CommandQuery.Queries
- Assembly
- Arbiter.CommandQuery.dll
Provides static helper methods for building common entity filters, queries, and sort expressions.
public static class EntityFilterBuilder
- Inheritance
-
EntityFilterBuilder
- Inherited Members
Remarks
This builder simplifies the creation of EntityFilter, EntityQuery, EntitySelect, and EntitySort instances for use in data-driven Blazor and WebAssembly applications.
Methods
CreateFilter(string, object?, string?)
Creates a filter for the specified field, value, and operator.
public static EntityFilter CreateFilter(string field, object? value, string? @operator = null)
Parameters
field
stringThe field or property name to filter on.
value
objectThe value to filter for.
operator
stringThe operator to use for the filter (e.g., "eq", "contains").
Returns
- EntityFilter
An instance of EntityFilter for the specified field, value, and operator.
CreateGroup(params IEnumerable<EntityFilter?>)
Creates a filter group for the specified filters using the "and" logic operator.
public static EntityFilter? CreateGroup(params IEnumerable<EntityFilter?> filters)
Parameters
filters
IEnumerable<EntityFilter>The list of filters to group.
Returns
- EntityFilter
An instance of EntityFilter representing the group, or null if no valid filters are provided.
Remarks
Any invalid filters will be removed from the group.
CreateGroup(string, params IEnumerable<EntityFilter?>)
Creates a filter group for the specified logic and filters.
public static EntityFilter? CreateGroup(string logic, params IEnumerable<EntityFilter?> filters)
Parameters
logic
stringThe group logic operator (e.g., "and" or "or").
filters
IEnumerable<EntityFilter>The list of filters to group.
Returns
- EntityFilter
An instance of EntityFilter representing the group, or null if no valid filters are provided.
Remarks
Any invalid filters will be removed from the group.
CreateSearchFilter(IEnumerable<string>, string)
Creates a search filter for the specified fields and search text.
public static EntityFilter? CreateSearchFilter(IEnumerable<string> fields, string searchText)
Parameters
fields
IEnumerable<string>The list of fields or property names to search on.
searchText
stringThe text to search for.
Returns
- EntityFilter
An instance of EntityFilter for the search text, or null if the fields or search text are invalid.
CreateSearchFilter<TModel>(string)
Creates a search filter for the specified model type.
public static EntityFilter? CreateSearchFilter<TModel>(string searchText) where TModel : class, ISupportSearch
Parameters
searchText
stringThe text to search for.
Returns
- EntityFilter
An instance of EntityFilter for the search text, or null if the search text is invalid.
Type Parameters
TModel
The type of the model. Must implement ISupportSearch.
CreateSearchQuery<TModel>(string, int, int)
Creates a search query for the specified model type.
public static EntityQuery? CreateSearchQuery<TModel>(string searchText, int page = 1, int pageSize = 20) where TModel : class, ISupportSearch
Parameters
searchText
stringThe text to search for.
page
intThe page number for the query. The default page is 1.
pageSize
intThe size of the page for the query. The default page size is 20.
Returns
- EntityQuery
An instance of EntityQuery configured for the search text, page, and page size, or null if the search text is invalid.
Type Parameters
TModel
The type of the model. Must implement ISupportSearch.
CreateSearchSelect<TModel>(string)
Creates a search select query for the specified model type.
public static EntitySelect? CreateSearchSelect<TModel>(string searchText) where TModel : class, ISupportSearch
Parameters
searchText
stringThe text to search for.
Returns
- EntitySelect
An instance of EntitySelect configured for the search text, or null if the search text is invalid.
Type Parameters
TModel
The type of the model. Must implement ISupportSearch.
CreateSort(string, string?)
Creates a sort expression for the specified field and direction.
public static EntitySort CreateSort(string field, string? direction = null)
Parameters
field
stringThe field or property name to sort on.
direction
stringThe sort direction (e.g., "asc" or "desc").
Returns
- EntitySort
An instance of EntitySort for the specified field and direction.
CreateSort<TModel>()
Creates a sort expression for the specified model type.
public static EntitySort? CreateSort<TModel>() where TModel : class, ISupportSearch
Returns
- EntitySort
An instance of EntitySort for the model type.
Type Parameters
TModel
The type of the model. Must implement ISupportSearch.