Muonroi.Data.Abstractions
1.0.0-alpha.16
dotnet add package Muonroi.Data.Abstractions --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.Data.Abstractions -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.Data.Abstractions" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.Data.Abstractions" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.Data.Abstractions" />
paket add Muonroi.Data.Abstractions --version 1.0.0-alpha.16
#r "nuget: Muonroi.Data.Abstractions, 1.0.0-alpha.16"
#:package Muonroi.Data.Abstractions@1.0.0-alpha.16
#addin nuget:?package=Muonroi.Data.Abstractions&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.Data.Abstractions&version=1.0.0-alpha.16&prerelease
Muonroi.Data.Abstractions
Repository, unit-of-work, and entity contracts that decouple your domain from any specific ORM or database driver.
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 inheritingMEntity:Add,UpdateAsync,DeleteAsync,AddBatchAsync,AddOrUpdateBatchAsync,UpdateBatchAsync,DeleteBatchAsync,BulkInsertAsync,SoftRestoreAsync, transactionalExecuteTransactionAsync/RollbackTransactionAsync.IMRepositoryBase<T>— relaxed variant that accepts anyclass, IEntityBase(noMEntityinheritance); addsExecuteStoredProcedureAsyncandExecuteStoredProcedureScalarAsync.IMQueries<T>— read-side contract:GetByIdAsync,GetByGuidAsync,GetAllAsync(plain and paged),GetByConditionAsync,GetPagedAsync<TDto>,FirstOrDefaultAsync,AnyAsync,ExistsAsync,CountAsync.IMUnitOfWork—SaveChangesAsync(returns row count) andSaveEntitiesAsync(returns correlationGuid).IMDataContext— thinSaveChangesAsynccontract for a single context.MultiDbUnitOfWork— concrete coordinator that fans outSaveChangesAsyncacross multipleIMDataContextinstances in sequence.IEntityBase/IEntityBase<TKey>— marker and typed-key entity contracts.IAuditable/IAuditable<TUserKey>—CreatedDate,UpdatedDate, and optional typedCreatedBy/UpdatedBy.ISiteScoped—SiteCodeproperty 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:
- Muonroi.Data.EntityFrameworkCore — EF Core implementation
- Muonroi.Data.Dapper — Dapper + MSSQL RLS implementation
Compatibility
- Target framework:
net8.0 - License: Apache-2.0 (OSS)
Related Packages
Muonroi.Data.EntityFrameworkCore— EF Core implementation ofIMRepository<T>,IMUnitOfWork, andIMDataContextMuonroi.Data.EntityFrameworkCore.Events— outbox / saga DbContext extensions built on top of EF CoreMuonroi.Data.Dapper— Dapper implementation with RLS support and stored-procedure helpersMuonroi.Core.Abstractions— core models (MEntity,MPagedResult,MVoidMethodResult) referenced by this package
License
Apache-2.0. See LICENSE-APACHE for details.
| 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 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. |
-
net8.0
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
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 | 94 | 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 | 85 | 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 |