CoreEx.Data
4.0.0-preview-1
dotnet add package CoreEx.Data --version 4.0.0-preview-1
NuGet\Install-Package CoreEx.Data -Version 4.0.0-preview-1
<PackageReference Include="CoreEx.Data" Version="4.0.0-preview-1" />
<PackageVersion Include="CoreEx.Data" Version="4.0.0-preview-1" />
<PackageReference Include="CoreEx.Data" />
paket add CoreEx.Data --version 4.0.0-preview-1
#r "nuget: CoreEx.Data, 4.0.0-preview-1"
#:package CoreEx.Data@4.0.0-preview-1
#addin nuget:?package=CoreEx.Data&version=4.0.0-preview-1&prerelease
#tool nuget:?package=CoreEx.Data&version=4.0.0-preview-1&prerelease
CoreEx.Data
Provides the
IUnitOfWorktransactional orchestration contract,DataResultmutation outcome types, data model base classes, and theQueryArgsConfig/QueryFilterParser/QueryOrderByParserpipeline for safe, explicitly-configured OData-style$filterand$orderbyLINQ query translation.
Overview
CoreEx.Data sits between the domain layer and persistence backends (SQL, EF Core, Cosmos). It defines the contracts and utilities that keep application services free of storage-specific types while still enabling rich, safe dynamic querying.
IUnitOfWork is the primary transactional boundary abstraction. Application services call TransactionAsync to scope a sequence of mutations and event enqueuing inside one transaction — regardless of whether the underlying store is SQL Server, PostgreSQL, or EF Core. The Events (IEventQueue) property on IUnitOfWork enables the transactional outbox pattern without coupling the service to any messaging infrastructure.
QueryArgsConfig is a configuration object that defines which fields a caller is allowed to filter and sort on, what operators each field supports, and how each field maps to the underlying model property. At request time, QueryExtensions.BuildQuery(IQueryable<T>, QueryArgs, QueryArgsConfig) parses the $filter and $orderby strings, validates them against the configuration, and appends the equivalent System.Linq.Dynamic.Core predicates to the IQueryable<T> — safely, with no arbitrary field exposure.
Key capabilities
- 🔁 Unit-of-work contract:
IUnitOfWorkprovidesTransactionAsyncand theEvents(IEventQueue) property for transactional outbox event enqueuing; storage implementations are injected and swappable. - 📦 Mutation result types:
DataResult(no value) andDataResult<T>carry aWasMutatedflag and optional mutated value, distinguishing "found and deleted" from "not found" without throwing exceptions. - 🗄️ Data model base classes:
ModelBase<TId>andReferenceDataModelBaseprovide ready-made persistence model types implementingIIdentifier<T>,IChangeLogEx,IETag, and commonIReferenceDataproperties respectively. - 🔍 Safe dynamic filter parsing:
QueryFilterParserparses OData-like$filterexpressions against an explicit field allow-list, translates them to LINQ predicates, and rejects unknown fields or disallowed operators with structured parse errors. - 📐 Safe dynamic order-by parsing:
QueryOrderByParserparses$orderbyexpressions against an explicit field allow-list and translates them to LINQ.OrderBy()/.ThenBy()calls. - ⚙️ Field-level configuration: Each field is configured with its CLR type, allowed operators, model property name/prefix, case normalization, null handling, and custom statement override via a fluent
QueryArgsConfig.WithFilter/WithOrderBybuilder. - 🏷️ Reference data filter fields:
QueryFilterReferenceDataFieldConfig<T>maps a reference dataCodestring in the filter to its underlyingIdfor persistence queries. - 🔗 IQueryable integration:
QueryExtensions.WhereandOrderByapplies the filter and order-by to anyIQueryable<T>.
Key types
| Type | Description |
|---|---|
IUnitOfWork |
Transactional unit-of-work contract: TransactionAsync, ExecuteAsync, AreEventsSupported, and Events (IEventQueue) for transactional outbox support. |
DataResult |
Readonly record struct carrying WasMutated for valueless mutation outcomes (e.g. delete). |
DataResult<T> |
Generic variant of DataResult adding the mutated Value; returned by create/update operations. |
IDataArgs |
Marker interface for strongly-typed data argument objects passed to IUnitOfWork overloads. |
QueryArgsConfig |
Root configuration builder for $filter and $orderby parsing; holds FilterParser, OrderByParser, and ParsingConfig; entry point via QueryArgsConfig.Create(). |
QueryFilterParser |
Configures and executes $filter parsing: AddField<T>, AddNullField, AddReferenceDataField<T>, WithDefault, OnQuery hooks, and Parse(filterString). |
QueryOrderByParser |
Configures and executes $orderby parsing: AddField, WithDefault, and Parse(orderByString). |
QueryExtensions |
IQueryable<T> extension methods Where and OrderBy apply the filter and order-by (respectively). |
QueryArgsParseResult |
Combined result of filter + order-by parsing: FilterResult, OrderByResult, HasErrors, and QueryStatement. |
QueryFilterParserResult |
Result of QueryFilterParser.Parse(): LINQ QueryStatement, parsed field values, and any ParseErrors. |
QueryOrderByParserResult |
Result of QueryOrderByParser.Parse(): ordered QueryStatement and any parse errors. |
ModelBase<TId> |
Abstract persistence model base implementing IIdentifier<T>, IChangeLogEx, IETag. |
ReferenceDataModelBase |
Persistence model base for reference data tables with Id, Code, Text, IsActive, SortOrder, StartDate, EndDate. |
Namespaces
| Namespace | Description |
|---|---|
Models |
ModelBase<TId> and ReferenceDataModelBase persistence model base classes. |
Querying |
QueryArgsConfig, QueryFilterParser, QueryOrderByParser, field configuration types, expression AST types, and QueryExtensions. |
Related Namespaces
CoreEx-QueryArgs(filter/orderby strings and paging),PagingArgs, andIEventQueueare defined in the rootCoreExpackage and consumed here.CoreEx.Database-IUnitOfWorkis implemented by the database unit-of-work;QueryArgsConfigis used by database query builders.CoreEx.EntityFrameworkCore- EF CoreIQueryable<T>extensions consumeQueryArgsConfigviaWhere/OrderBy.
AI Usage Guide
An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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. |
-
net10.0
- CoreEx.Events (>= 4.0.0-preview-1)
- System.Linq.Dynamic.Core (>= 1.7.1)
-
net8.0
- CoreEx.Events (>= 4.0.0-preview-1)
- System.Linq.Dynamic.Core (>= 1.7.1)
-
net9.0
- CoreEx.Events (>= 4.0.0-preview-1)
- System.Linq.Dynamic.Core (>= 1.7.1)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on CoreEx.Data:
| Package | Downloads |
|---|---|
|
CoreEx.Database
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.Database.SqlServer
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.EntityFrameworkCore
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.Cosmos
CoreEx .NET Cosmos DB extras. |
|
|
CoreEx.Database.Postgres
Core .NET extensions and abstractions for the development of backend services. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0-preview-1 | 65 | 6/20/2026 |
| 3.31.0 | 7,087 | 2/1/2025 |
| 3.30.2 | 435 | 12/11/2024 |
| 3.30.1 | 405 | 12/9/2024 |
| 3.30.0 | 2,549 | 11/21/2024 |
| 3.29.0 | 6,305 | 11/19/2024 |
| 3.28.0 | 424 | 11/9/2024 |
| 3.27.3 | 860 | 10/23/2024 |
| 3.27.2 | 385 | 10/17/2024 |
| 3.27.1 | 678 | 10/15/2024 |
| 3.27.0 | 1,360 | 10/11/2024 |
| 3.26.0 | 434 | 10/3/2024 |
| 3.25.6 | 1,091 | 10/2/2024 |
| 3.25.5 | 538 | 9/25/2024 |
| 3.25.4 | 553 | 9/24/2024 |
| 3.25.3 | 482 | 9/18/2024 |
| 3.25.2 | 531 | 9/17/2024 |
| 3.25.1 | 670 | 9/16/2024 |
| 3.25.0 | 479 | 9/10/2024 |