CoreEx.Data 4.0.0

dotnet add package CoreEx.Data --version 4.0.0
                    
NuGet\Install-Package CoreEx.Data -Version 4.0.0
                    
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.

                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.

                    
Directory.Packages.props

                    
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
                    
#r "nuget: CoreEx.Data, 4.0.0"
                    
#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
                    
#: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
                    
Install as a Cake Addin
#tool nuget:?package=CoreEx.Data&version=4.0.0
                    
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, 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 — 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 carry a WasMutated flag and optional mutated value, distinguishing "found and deleted" from "not found" without throwing exceptions.
  • 🗄️ Data model base classes: ModelBase and ReferenceDataModelBase provide ready-made persistence model types implementing IIdentifier, 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 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.
  • 🧩 Multi-set query contract: IMultiSetArgsCore is the minimal, provider-agnostic base for a single result-set within a multi-set query (MinimumRows, MaximumRows, StopOnNull, InvokeResult()) - CoreEx.Database.Extended.IMultiSetArgs (positional/ordered relational result sets) and CoreEx.Cosmos.Extended.IMultiSetArgs (discriminator-keyed Cosmos DB document sets) each extend it with their own provider-specific matching mechanism, so a future NoSQL provider (e.g. Mongo) can reuse the same base contract and row-count semantics.

Key types

Type Description
IUnitOfWork Transactional unit-of-work contract: TransactionAsync, AreEventsSupported, and Events (IEventQueue) for transactional outbox support.
DataResult Readonly record struct carrying WasMutated for valueless mutation outcomes (e.g. delete).
DataResult 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, AddNullField, AddReferenceDataField, WithDefault, OnQuery hooks, and Parse(filterString).
QueryOrderByParser Configures and executes $orderby parsing: AddField, WithDefault, and Parse(orderByString).
QueryExtensions IQueryable 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 Abstract persistence model base implementing IIdentifier, IChangeLogEx, IETag.
ReferenceDataModelBase Persistence model base for reference data tables with Id, Code, Text, Description, IsActive, SortOrder, StartsOn, EndsOn.
IMultiSetArgsCore Provider-agnostic base contract for one result-set within a multi-set query: MinimumRows, MaximumRows, StopOnNull, InvokeResult(). Extended by CoreEx.Database.Extended.IMultiSetArgs (relational, positional) and CoreEx.Cosmos.Extended.IMultiSetArgs (Cosmos DB, discriminator-keyed); deliberately excludes any provider-specific matching mechanism (e.g. relational's DatasetRecord(), Cosmos's TypeDiscriminator/AddItem).

Namespaces

Namespace Description
Models ModelBase 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; Extended.IMultiSetArgs/IMultiSetArgs/MultiSetSingleArgs/MultiSetCollArgs extend IMultiSetArgsCore for positional, ordered relational multi-set queries.
  • CoreEx.Cosmos - Extended.IMultiSetArgs/IMultiSetArgs/MultiSetSingleArgs/MultiSetCollArgs extend IMultiSetArgsCore for discriminator-keyed Cosmos DB multi-set queries.
  • CoreEx.EntityFrameworkCore - EF Core IQueryable 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 (8)

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.UnitTesting

Core .NET extensions and abstractions for the testing of backend services.

CoreEx.Cosmos

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 215 9/21/2026
4.0.0-preview-5 247 8/23/2026
4.0.0-preview-4 232 8/21/2026
4.0.0-preview-3 341 8/4/2026
4.0.0-preview-2 222 7/10/2026
4.0.0-preview-1 229 6/20/2026
3.31.0 8,745 2/1/2025
3.30.2 460 12/11/2024
3.30.1 421 12/9/2024
3.30.0 2,873 11/21/2024
3.29.0 7,979 11/19/2024
3.28.0 453 11/9/2024
3.27.3 888 10/23/2024
3.27.2 417 10/17/2024
3.27.1 715 10/15/2024
3.27.0 1,414 10/11/2024
3.26.0 458 10/3/2024
3.25.6 1,136 10/2/2024
3.25.5 562 9/25/2024
3.25.4 582 9/24/2024
Loading failed