Muonroi.Data.Abstractions 1.0.0-alpha.16

This is a prerelease version of Muonroi.Data.Abstractions.
dotnet add package Muonroi.Data.Abstractions --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.Data.Abstractions -Version 1.0.0-alpha.16
                    
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="Muonroi.Data.Abstractions" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.Data.Abstractions" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Data.Abstractions" />
                    
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 Muonroi.Data.Abstractions --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.Data.Abstractions, 1.0.0-alpha.16"
                    
#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 Muonroi.Data.Abstractions@1.0.0-alpha.16
                    
#: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=Muonroi.Data.Abstractions&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Data.Abstractions&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.Data.Abstractions

Repository, unit-of-work, and entity contracts that decouple your domain from any specific ORM or database driver.

NuGet License: Apache 2.0

This package ships contracts only — interfaces, marker types, and the MultiDbUnitOfWork coordinator class. There is no runtime ORM behavior here. Your application domain layer takes a dependency on these abstractions; the implementation is provided by Muonroi.Data.EntityFrameworkCore (EF Core) or Muonroi.Data.Dapper (raw SQL / RLS), both of which reference this package.

Installation

dotnet add package Muonroi.Data.Abstractions --prerelease

Quick Start

Because this is a contracts package, the typical usage is implementing the interfaces in an infrastructure project and consuming them in the domain/application layer.

1. Define your entity

using Muonroi.Data.Abstractions.Entities;

// Implement IEntityBase<TKey> for a typed primary key.
// Add IAuditable<Guid> to track created/updated timestamps and user.
public class Order : IEntityBase<long>, IAuditable<Guid>
{
    public long Id { get; set; }
    public string Reference { get; set; } = string.Empty;

    // IAuditable<Guid>
    public DateTime? CreatedDate { get; set; }
    public DateTime? UpdatedDate { get; set; }
    public Guid? CreatedBy { get; set; }
    public Guid? UpdatedBy { get; set; }
}

2. Declare a repository interface using IMRepositoryBase

using Muonroi.Data.Abstractions.Repositories;

// IMRepositoryBase<T> accepts any class implementing IEntityBase —
// no MEntity inheritance required.
public interface IOrderRepository : IMRepositoryBase<Order>
{
    Task<Order?> FindByReferenceAsync(string reference, CancellationToken ct = default);
}

3. Use the unit of work in an application service

using Muonroi.Data.Abstractions.UnitOfWork;

public class PlaceOrderHandler(IOrderRepository orders)
{
    public async Task HandleAsync(PlaceOrderCommand cmd, CancellationToken ct)
    {
        var order = new Order { Reference = cmd.Reference };
        orders.Add(order);
        await orders.UnitOfWork.SaveEntitiesAsync(ct);
    }
}

The concrete IOrderRepository implementation (EF Core or Dapper) is registered by the infrastructure package — see Muonroi.Data.EntityFrameworkCore or Muonroi.Data.Dapper.

4. Coordinate multiple DbContexts with MultiDbUnitOfWork

using Muonroi.Data.Abstractions.UnitOfWork;

// Pass any number of IMDataContext implementors.
var uow = new MultiDbUnitOfWork(primaryContext, auditContext);
int written = await uow.SaveChangesAsync(cancellationToken);

Features

  • IMRepository<T> — full CRUD contract for entities inheriting MEntity: Add, UpdateAsync, DeleteAsync, AddBatchAsync, AddOrUpdateBatchAsync, UpdateBatchAsync, DeleteBatchAsync, BulkInsertAsync, SoftRestoreAsync, transactional ExecuteTransactionAsync / RollbackTransactionAsync.
  • IMRepositoryBase<T> — relaxed variant that accepts any class, IEntityBase (no MEntity inheritance); adds ExecuteStoredProcedureAsync and ExecuteStoredProcedureScalarAsync.
  • IMQueries<T> — read-side contract: GetByIdAsync, GetByGuidAsync, GetAllAsync (plain and paged), GetByConditionAsync, GetPagedAsync<TDto>, FirstOrDefaultAsync, AnyAsync, ExistsAsync, CountAsync.
  • IMUnitOfWorkSaveChangesAsync (returns row count) and SaveEntitiesAsync (returns correlation Guid).
  • IMDataContext — thin SaveChangesAsync contract for a single context.
  • MultiDbUnitOfWork — concrete coordinator that fans out SaveChangesAsync across multiple IMDataContext instances in sequence.
  • IEntityBase / IEntityBase<TKey> — marker and typed-key entity contracts.
  • IAuditable / IAuditable<TUserKey>CreatedDate, UpdatedDate, and optional typed CreatedBy / UpdatedBy.
  • ISiteScopedSiteCode property for schema-divergent multi-tenancy scenarios.

API Reference

Type Kind Purpose
IMRepository<T> Interface Full write contract for MEntity-derived entities
IMRepositoryBase<T> Interface Relaxed write contract for any IEntityBase entity; adds stored-procedure helpers
IMQueries<T> Interface Read-side queries: by id, by guid, paged, filtered, projected
IMUnitOfWork Interface Saves changes; exposes SaveChangesAsync (int) and SaveEntitiesAsync (Guid)
IMDataContext Interface Single-context save contract; implemented by EF DbContext wrappers
MultiDbUnitOfWork Class Fans out SaveChangesAsync across multiple IMDataContext instances
IEntityBase Interface Marker for all Muonroi entities
IEntityBase<TKey> Interface Adds typed Id property
IAuditable Interface CreatedDate / UpdatedDate timestamps
IAuditable<TUserKey> Interface Extends IAuditable with typed CreatedBy / UpdatedBy
ISiteScoped Interface SiteCode for site-scoped multi-tenancy

Samples

No standalone sample is provided for this contracts package. See the implementation packages for runnable examples:

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)

License

Apache-2.0. See LICENSE-APACHE for details.

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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Muonroi.Data.Abstractions:

Package Downloads
Muonroi.Data.EntityFrameworkCore

Entity Framework Core infrastructure for Muonroi: MDbContext with audit, soft-delete, multi-tenant filters, and repository base.

Muonroi.AspNetCore

ASP.NET Core integration: auto-CRUD controllers, middleware pipeline, license protection, and Muonroi hosting extensions.

Muonroi.Data.Dapper

Dapper integration for Muonroi: lightweight read-side repository, multi-tenant query filtering, and connection factory.

Muonroi.Mapping.Abstractions

Entity-DTO mapping contracts with template method pattern for schema-divergent multi-tenancy.

Muonroi.Services.Abstractions

Generic service base with virtual hook methods for schema-divergent multi-tenancy. Core provides CRUD; site overrides hooks.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 104 6/22/2026
1.0.0-alpha.15 177 5/31/2026
1.0.0-alpha.14 171 5/15/2026
1.0.0-alpha.13 152 5/2/2026
1.0.0-alpha.12 95 4/2/2026
1.0.0-alpha.11 150 4/2/2026
1.0.0-alpha.9 86 3/30/2026
1.0.0-alpha.8 174 3/28/2026
1.0.0-alpha.7 78 3/27/2026
1.0.0-alpha.5 67 3/27/2026
1.0.0-alpha.4 67 3/27/2026
1.0.0-alpha.3 68 3/27/2026
1.0.0-alpha.2 68 3/26/2026
1.0.0-alpha.1 105 3/8/2026