Carubbi.DAL 2.1.0

dotnet add package Carubbi.DAL --version 2.1.0
                    
NuGet\Install-Package Carubbi.DAL -Version 2.1.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.
<PackageReference Include="Carubbi.DAL" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Carubbi.DAL" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Carubbi.DAL" />
                    
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 Carubbi.DAL --version 2.1.0
                    
#r "nuget: Carubbi.DAL, 2.1.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 Carubbi.DAL@2.1.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=Carubbi.DAL&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Carubbi.DAL&version=2.1.0
                    
Install as a Cake Tool

NuGet Carubbi.DAL NuGet downloads

Carubbi.DAL

Stored-procedure based, database-agnostic micro-ORM for .NET 10.

Packages

Project Package
src/Carubbi.DAL Carubbi.DAL
src/Carubbi.DAL.Interfaces Carubbi.DAL.Interfaces

Requirements

  • .NET 10 SDK
  • A provider-specific IDaoFactory (e.g. SqlClient-based) registered in DI

Usage

// Program.cs
services.AddCarubbiDal(options =>
{
    options.ConnectionString = configuration.GetConnectionString("Default")!;
    options.SchemaName = "dbo";
    options.StoredProcedurePrefix = "SP_";
});
services.AddSingleton<IDaoFactory, SqlDaoFactory>();

// Entity
public sealed class Customer
{
    [Key]
    public int Id { get; set; }
    public string? Name { get; set; }
    [NonPersisted]
    public string? Computed { get; set; }
}

// Query
public sealed class Customers
{
    private readonly IDao<Customer> _customers;
    public Customers(IDao<Customer> customers) => _customers = customers;

    public Task<IReadOnlyList<Customer>> AllAsync(CancellationToken ct = default)
        => _customers.ListAsync(ct);

    public Task<Customer?> ByIdAsync(int id, CancellationToken ct = default)
        => _customers.GetAsync(new Customer { Id = id }, ct);

    public Task<Customer> SaveAsync(Customer customer, CancellationToken ct = default)
        => _customers.SaveAsync(customer, ct);

    public Task<int> DeleteAsync(Customer customer, CancellationToken ct = default)
        => _customers.DeleteAsync(customer, ct);
}

// Explicit transaction across multiple DAOs
await using var uow = new UnitOfWork(factory, Options.Create(options));
await uow.OpenAsync(ct);
var dao = new Dao<Customer>(factory, Options.Create(options), mapper: null, unitOfWork: uow);
await dao.SaveAsync(customer, ct);
await uow.CommitAsync(ct);

Procedure naming: {Schema}.{Prefix}{Entity}_{Operation} where operation is LIST_ALL, LIST_{Filter}, GET, SAVE, DELETE.

Configuration section:

{
  "Dal": {
    "ConnectionString": "Server=.;Database=App;Trusted_Connection=True;",
    "SchemaName": "dbo",
    "StoredProcedurePrefix": "SP_",
    "InputParameterPrefix": "",
    "OutputFieldPrefix": ""
  }
}
services.AddCarubbiDal(configuration.GetSection(DalOptions.SectionName));

Breaking changes in v2.0.0

  • Target: .NET Framework 4.7.2 → .NET 10.
  • Carubbi.ServiceLocator removed; use Microsoft DI (AddCarubbiDal + IDaoFactory).
  • Portuguese API renamed to English async: ObterGetAsync, ListarListAsync, SalvarSaveAsync, ExcluirDeleteAsync, CampoChaveKey, CampoNaoPersistivelNonPersisted, IDAOIDao, IDAOFactoryIDaoFactory.
  • UnitOfWork no longer commits on Dispose; call CommitAsync explicitly. Disposing an uncommitted scope rolls back.
  • System.Configuration connection lookup replaced by DalOptions.ConnectionString.
  • AddWithValue reflection replaced by typed CreateParameter; pre-1753 dates clamp to 1753-01-01.

Building and testing locally

dotnet build Carubbi.DAL.slnx -c Release
dotnet run --project tests/Carubbi.DAL.Tests/Carubbi.DAL.Tests.csproj -c Release --no-build

Integration tests (Docker required)

tests/Carubbi.DAL.IntegrationTests spins up SQL Server 2022 via Testcontainers (Testcontainers.MsSql), creates the Customer table plus the SP_Customer_* procedures, and exercises the full save/get/list/delete cycle, explicit UnitOfWork commit/rollback, FK-violation wrapping, and the date clamp against the real engine:

dotnet run --project tests/Carubbi.DAL.IntegrationTests/Carubbi.DAL.IntegrationTests.csproj -c Release --no-build

Releasing

Push tag v* triggers publish via trusted publishing:

git tag v2.1.0
git push origin master v2.1.0

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 84 9/4/2026
2.0.0 94 9/4/2026
1.1.0 1,386 8/21/2018
1.0.0 1,129 8/20/2018