Carubbi.DAL.Interfaces
2.1.0
dotnet add package Carubbi.DAL.Interfaces --version 2.1.0
NuGet\Install-Package Carubbi.DAL.Interfaces -Version 2.1.0
<PackageReference Include="Carubbi.DAL.Interfaces" Version="2.1.0" />
<PackageVersion Include="Carubbi.DAL.Interfaces" Version="2.1.0" />
<PackageReference Include="Carubbi.DAL.Interfaces" />
paket add Carubbi.DAL.Interfaces --version 2.1.0
#r "nuget: Carubbi.DAL.Interfaces, 2.1.0"
#:package Carubbi.DAL.Interfaces@2.1.0
#addin nuget:?package=Carubbi.DAL.Interfaces&version=2.1.0
#tool nuget:?package=Carubbi.DAL.Interfaces&version=2.1.0
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.ServiceLocatorremoved; use Microsoft DI (AddCarubbiDal+IDaoFactory).- Portuguese API renamed to English async:
Obter→GetAsync,Listar→ListAsync,Salvar→SaveAsync,Excluir→DeleteAsync,CampoChave→Key,CampoNaoPersistivel→NonPersisted,IDAO→IDao,IDAOFactory→IDaoFactory. UnitOfWorkno longer commits onDispose; callCommitAsyncexplicitly. Disposing an uncommitted scope rolls back.System.Configurationconnection lookup replaced byDalOptions.ConnectionString.AddWithValuereflection replaced by typedCreateParameter; 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 | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Carubbi.DAL.Interfaces:
| Package | Downloads |
|---|---|
|
Carubbi.DAL
Stored-procedure based, database-agnostic micro-ORM for .NET |
GitHub repositories
This package is not used by any popular GitHub repositories.