Carubbi.DAL
2.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Carubbi.DAL --version 2.0.0
NuGet\Install-Package Carubbi.DAL -Version 2.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.
<PackageReference Include="Carubbi.DAL" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Carubbi.DAL" Version="2.0.0" />
<PackageReference Include="Carubbi.DAL" />
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.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Carubbi.DAL, 2.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 Carubbi.DAL@2.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=Carubbi.DAL&version=2.0.0
#tool nuget:?package=Carubbi.DAL&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
Releasing
Push tag v* triggers publish via trusted publishing:
git tag v2.0.0
git push origin master v2.0.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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Carubbi.DAL.Interfaces (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.