CoreEx.Data 4.0.0-preview-1

This is a prerelease version of CoreEx.Data.
dotnet add package CoreEx.Data --version 4.0.0-preview-1
                    
NuGet\Install-Package CoreEx.Data -Version 4.0.0-preview-1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoreEx.Data" Version="4.0.0-preview-1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreEx.Data" Version="4.0.0-preview-1" />
                    
Directory.Packages.props
<PackageReference Include="CoreEx.Data" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoreEx.Data --version 4.0.0-preview-1
                    
#r "nuget: CoreEx.Data, 4.0.0-preview-1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoreEx.Data@4.0.0-preview-1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoreEx.Data&version=4.0.0-preview-1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CoreEx.Data&version=4.0.0-preview-1&prerelease
                    
Install as a Cake Tool

CoreEx.Data

Provides the IUnitOfWork transactional orchestration contract, DataResult mutation outcome types, data model base classes, and the QueryArgsConfig / QueryFilterParser / QueryOrderByParser pipeline for safe, explicitly-configured OData-style $filter and $orderby LINQ 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: IUnitOfWork provides TransactionAsync and the Events (IEventQueue) property for transactional outbox event enqueuing; storage implementations are injected and swappable.
  • 📦 Mutation result types: DataResult (no value) and DataResult<T> carry a WasMutated flag and optional mutated value, distinguishing "found and deleted" from "not found" without throwing exceptions.
  • 🗄️ Data model base classes: ModelBase<TId> and ReferenceDataModelBase provide ready-made persistence model types implementing IIdentifier<T>, IChangeLogEx, IETag, and common IReferenceData properties respectively.
  • 🔍 Safe dynamic filter parsing: QueryFilterParser parses OData-like $filter expressions 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: QueryOrderByParser parses $orderby expressions 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 / WithOrderBy builder.
  • 🏷️ Reference data filter fields: QueryFilterReferenceDataFieldConfig<T> maps a reference data Code string in the filter to its underlying Id for persistence queries.
  • 🔗 IQueryable integration: QueryExtensions.Where and OrderBy applies the filter and order-by to any IQueryable<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.
  • CoreEx - QueryArgs (filter/orderby strings and paging), PagingArgs, and IEventQueue are defined in the root CoreEx package and consumed here.
  • CoreEx.Database - IUnitOfWork is implemented by the database unit-of-work; QueryArgsConfig is used by database query builders.
  • CoreEx.EntityFrameworkCore - EF Core IQueryable<T> extensions consume QueryArgsConfig via Where/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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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