Class Filter
- Namespace
- GroupeIsa.Neos.Application.Filters
- Assembly
- GroupeIsa.Neos.Application.Abstractions.dll
Represents the filter of a property.
[JsonConverter(typeof(FilterJsonConverter))]
public class Filter : ICloneable
- Inheritance
-
Filter
- Implements
- Inherited Members
Constructors
Filter()
Initializes a new instance of the Filter class.
public Filter()
Filter(FilterCondition)
Initializes a new instance of the Filter class.
public Filter(FilterCondition condition)
Parameters
condition
FilterConditionFilter condition.
Filter(FilterCondition?, FilterLogicalOperator, params Filter[])
Initializes a new instance of the Filter class.
public Filter(FilterCondition? condition, FilterLogicalOperator logicalOperator, params Filter[] children)
Parameters
condition
FilterConditionFilter condition.
logicalOperator
FilterLogicalOperatorFilter operator logical.
children
Filter[]Children filter collection.
Filter(params Filter[])
Initializes a new instance of the Filter class.
public Filter(params Filter[] children)
Parameters
children
Filter[]Children filter collection.
Filter(string, FilterOperator, params object?[])
Initializes a new instance of the Filter class.
public Filter(string propertyPath, FilterOperator filterOperator, params object?[] values)
Parameters
propertyPath
stringProperty path.
filterOperator
FilterOperatorCondition operator.
values
object[]Value of the filter condition.
Properties
Children
Gets a children filter collection.
public IEnumerable<Filter> Children { get; }
Property Value
Condition
Gets or sets the filter condition.
public FilterCondition? Condition { get; set; }
Property Value
IsCondition
Gets a value indicating whether if the filter is a condition.
public bool IsCondition { get; }
Property Value
IsEmpty
Gets a value indicating whether if the filter is empty.
public bool IsEmpty { get; }
Property Value
IsSimple
Gets a value indicating whether if the filter is composed of only condition filters linked by the "And" operator for all filters.
public bool IsSimple { get; }
Property Value
LogicalOperator
Gets the filter logical operator.
public FilterLogicalOperator LogicalOperator { get; }
Property Value
Methods
Add(Filter)
Adds the specified filter to the children of this filter.
public Filter Add(Filter filter)
Parameters
filter
FilterThe filter to add.
Returns
- Filter
Return the filter with the specified filter added.
Clear()
Removes all filters from the filter.
public void Clear()
Clone()
Creates a shallow copy of the filter.
public object Clone()
Returns
- object
A shallow copy of the filter.
ConvertFromJson(string)
Converts from JSON.
public static Filter ConvertFromJson(string value)
Parameters
value
stringValue.
Returns
ConvertToJson()
Converts to JSON.
public string ConvertToJson()
Returns
- string
string representation.
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
- bool
true if the specified object is equal to the current object; otherwise, false.
Expand(FilterLogicalOperator?)
Expands a filter.
This filter becomes a child.
public void Expand(FilterLogicalOperator? logicalOperator = null)
Parameters
logicalOperator
FilterLogicalOperator?The logical operator.
Examples
The following example shows how to build the filter : ShipCountry = 'France' or ShipCountry = 'Spain'.
var filter = new Filter("ShipCountry", FilterOperator.Equal, "France");
filter.Expand(FilterLogicalOperator.Or);
filter.Add(new Filter("ShipCountry", FilterOperator.Equal, "Spain"));
Find(string)
Returns the first filter found whose property path is the specified property path.
public Filter? Find(string propertyPath)
Parameters
propertyPath
stringProperty path.
Returns
- Filter
The first filter found whose property path is the specified property path.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Join(Filter, FilterLogicalOperator)
Joins the specified filter to this filter with the specified operator.
public Filter Join(Filter filter, FilterLogicalOperator logicalOperator)
Parameters
filter
FilterThe filter to add.
logicalOperator
FilterLogicalOperatorThe logical operator.
Returns
- Filter
Return the filter with the specified filter added.
Remove(Filter)
Removes a specific filter recursively.
public bool Remove(Filter filter)
Parameters
filter
FilterThe filter to remove.
Returns
- bool
Return true if removes a specific filter recursively.
ToODataString()
Converts the filter to OData string.
public string ToODataString()
Returns
- string
The OData string.
Exceptions
- NotSupportedException
When the filter cannot be converted.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToText()
Converts to human readable text.
public string? ToText()
Returns
- string
A human readable text.