DataFilter.Core
1.1.4
dotnet add package DataFilter.Core --version 1.1.4
NuGet\Install-Package DataFilter.Core -Version 1.1.4
<PackageReference Include="DataFilter.Core" Version="1.1.4" />
<PackageVersion Include="DataFilter.Core" Version="1.1.4" />
<PackageReference Include="DataFilter.Core" />
paket add DataFilter.Core --version 1.1.4
#r "nuget: DataFilter.Core, 1.1.4"
#:package DataFilter.Core@1.1.4
#addin nuget:?package=DataFilter.Core&version=1.1.4
#tool nuget:?package=DataFilter.Core&version=1.1.4
DataFilter.Core
The foundation of the DataFilter library, providing pure filtering logic, abstractions, and standard data models.
Visual customization: UI packages only — overview in CUSTOMIZATION.md.
NuGet integration
Install the package
dotnet add package DataFilter.Core
Target frameworks
net8.0, net9.0, netstandard2.0, netstandard2.1
Dependencies
None (UI-independent). Optional companion packages: DataFilter.Filtering.ExcelLike for Excel-style descriptors, DataFilter.Expressions.Server for LINQ translation.
Visual theming (colors, styles) lives in UI packages — see CUSTOMIZATION.md and FilterTheme in DataFilter.PlatformShared.
Quick start
using DataFilter.Core.Abstractions;
using DataFilter.Core.Enums;
using DataFilter.Core.Models;
using DataFilter.Core.Pipeline;
using DataFilter.Core.Services;
// In-memory filtering
var context = new FilterContext();
context.AddOrUpdateDescriptor(new FilterDescriptor
{
PropertyName = "Department",
Operator = FilterOperator.Equals,
Value = "IT"
});
var engine = new ReflectionFilterEngine();
var filtered = engine.Apply(employees, typeof(Employee), context.Descriptors);
// Filter pipeline preset (ordered criteria + multi-column sort)
var snapshot = new FilterPipelineSnapshot();
FilterPipelineSnapshotEditor.AddRootCriterion(snapshot, "IsActive", nameof(FilterOperator.Equals), true);
FilterPipelineSnapshotEditor.AddSort(snapshot, "Name", isDescending: false);
var pipeline = FilterPipelineSnapshotMapper.ToPipeline(snapshot);
context.ReplaceDescriptors(FilterPipelineCompiler.Compile(pipeline));
Structure
- Abstractions:
IFilterEngine,IFilterDescriptor,IFilterContext,IAsyncDataProvider, etc. - Engine:
FilterExpressionBuilder,ReflectionFilterEngine,FilterEvaluator(wildcard text matching). - Models:
FilterSnapshot,FilterPipelineSnapshot,SortDescriptor,PagedResult. - Pipeline (
Pipeline/):FilterPipeline,CriterionPipelineNode,GroupPipelineNode— editable graph for UI scenarios (order, named groups, toggles). - Services:
FilterSnapshotBuilder,FilterPipelineCompiler,FilterPipelineSnapshotMapper,FilterPipelineSnapshotEditor,FilterPipelineInterop,FilterPipelineContextExtensions.
Key Concepts
Wildcards in text operators (*, ?)
Core text operators (Equals, NotEquals, Contains, NotContains, StartsWith, EndsWith) support wildcard patterns:
*matches any sequence of characters?matches a single character
This behavior is implemented in FilterEvaluator and FilterExpressionBuilder, so it applies consistently to in-memory filtering and compiled expressions. Persisted presets that store a text operator + pattern replay correctly without UI-specific logic.
FilterSnapshot
A serializable representation of a filtering state that can be passed between layers (e.g., from Blazor UI to Web API). Describes what is filtered using flat or nested FilterSnapshotEntry rows (including logical groups for Excel-style column scopes).
Filter pipeline
For applications that need an ordered list of criteria, named groups, enable/disable flags, and JSON presets, use the pipeline model:
| Type | Role |
|---|---|
FilterPipeline |
Root list of nodes + RootCombineOperator (AND/OR between top-level nodes). |
CriterionPipelineNode |
Leaf: property name, operator name (FilterOperator), and value (same shapes as FilterSnapshotEntry). |
GroupPipelineNode |
Named group: DisplayName, CombineOperator, ordered Children. |
FilterPipelineCompiler |
Walks enabled nodes and returns IReadOnlyList<IFilterDescriptor> (groups become FilterGroup with internal keys __group_{id}; multiple root OR branches compile to one FilterGroup with OR). |
FilterPipelineSnapshot / FilterPipelineNodeDto |
Versioned DTO for presets. Nodes and SortEntries are mutable lists — edit in memory and apply without JSON. |
FilterPipelineSnapshotMapper |
Maps between the graph and the DTO; normalizes JsonElement values after deserialization. |
FilterPipelineSnapshotEditor |
Client-side CRUD on snapshot criteria and sort (AddRootCriterion, AddSort, RemoveNode, MoveSort, Clone, …). |
FilterPipelineInterop.FromLegacySnapshot |
Builds a FilterPipeline from an existing IFilterSnapshot (e.g. after using column filters). |
Apply to runtime state with FilterContext.ReplaceDescriptors(FilterPipelineCompiler.Compile(pipeline)) or FilterPipelineContextExtensions.ApplyToContext(pipeline, filterContext). This replaces the entire descriptor list; it does not merge by property name (unlike AddOrUpdateDescriptor).
// Edit snapshot in memory, then compile and apply
var snapshot = FilterPipelineSnapshotEditor.Clone(existing);
FilterPipelineSnapshotEditor.AddRootCriterion(snapshot, "Name", nameof(FilterOperator.StartsWith), "A");
var pipeline = FilterPipelineSnapshotMapper.ToPipeline(snapshot);
context.ReplaceDescriptors(FilterPipelineCompiler.Compile(pipeline));
IAsyncDataProvider
Implement this interface to provide data asynchronously from any source (SQL, NoSQL, API).
public interface IAsyncDataProvider<T>
{
Task<PagedResult<T>> FetchDataAsync(IFilterContext context, CancellationToken cancellationToken = default);
Task<IEnumerable<object>> FetchDistinctValuesAsync(string propertyName, string searchText = "", CancellationToken cancellationToken = default);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 10.0.8)
-
.NETStandard 2.1
- System.Text.Json (>= 10.0.8)
-
net8.0
- System.Text.Json (>= 10.0.8)
-
net9.0
- System.Text.Json (>= 10.0.8)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on DataFilter.Core:
| Package | Downloads |
|---|---|
|
DataFilter.Filtering.ExcelLike
Package Description |
|
|
DataFilter.PlatformShared
Package Description |
|
|
DataFilter.Wpf
Package Description |
|
|
DataFilter.Expressions.Server
Package Description |
|
|
DataFilter.Blazor
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.