CaeriusNet 10.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CaeriusNet --version 10.3.0
                    
NuGet\Install-Package CaeriusNet -Version 10.3.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="CaeriusNet" Version="10.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CaeriusNet" Version="10.3.0" />
                    
Directory.Packages.props
<PackageReference Include="CaeriusNet" />
                    
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 CaeriusNet --version 10.3.0
                    
#r "nuget: CaeriusNet, 10.3.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 CaeriusNet@10.3.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=CaeriusNet&version=10.3.0
                    
Install as a Cake Addin
#tool nuget:?package=CaeriusNet&version=10.3.0
                    
Install as a Cake Tool

CaeriusNet

High-performance micro-ORM for C# 14 / .NET 10 that executes SQL Server Stored Procedures, maps DTOs at compile-time, passes Table-Valued Parameters, and caches results — all in a single package, zero reflection at runtime.

Installation

dotnet add package CaeriusNet

Prerequisites

  • .NET 10 or later
  • SQL Server 2019 or later

Quick Start

1. Configure (Program.cs)

// Standard
CaeriusNetBuilder.Create(services)
    .WithSqlServer("Server=.;Database=MyDb;Trusted_Connection=True;")
    .Build();

// .NET Aspire
CaeriusNetBuilder.Create(builder)
    .WithAspireSqlServer("CaeriusNet")
    .WithAspireRedis()
    .Build();

2. Define a DTO

Source-generated (recommended):

[GenerateDto]
public sealed partial record ProductDto(int Id, string Name, decimal Price);
// Generates: ISpMapper<ProductDto> with MapFromDataReader at compile-time

Manual:

public sealed record ProductDto(int Id, string Name, decimal Price) : ISpMapper<ProductDto>
{
    public static ProductDto MapFromDataReader(SqlDataReader reader)
        => new(reader.GetInt32(0), reader.GetString(1), reader.GetDecimal(2));
}

3. Execute a Stored Procedure

var sp = new StoredProcedureParametersBuilder("dbo", "sp_GetProducts", capacity: 1)
    .AddParameter("CategoryId", categoryId, SqlDbType.Int)
    .Build();

IReadOnlyCollection<ProductDto> products =
    await dbContext.QueryAsReadOnlyCollectionAsync<ProductDto>(sp, ct);

Table-Valued Parameters (TVP)

Source-generated:

[GenerateTvp(Schema = "dbo", TvpName = "tvp_int")]
public sealed partial record IntTvp(int Value);

Manual:

public sealed record OrderLineDto(int ProductId, int Qty) : ITvpMapper<OrderLineDto>
{
    public static string TvpTypeName => "dbo.tvp_OrderLine";

    public static IEnumerable<SqlDataRecord> MapAsSqlDataRecords(IEnumerable<OrderLineDto> items)
    {
        var meta = new[] { new SqlMetaData("ProductId", SqlDbType.Int), new SqlMetaData("Qty", SqlDbType.Int) };
        foreach (var item in items)
        {
            var record = new SqlDataRecord(meta);
            record.SetInt32(0, item.ProductId);
            record.SetInt32(1, item.Qty);
            yield return record;
        }
    }
}

Usage:

var sp = new StoredProcedureParametersBuilder("dbo", "sp_BulkInsert", capacity: 1)
    .AddTvpParameter("OrderLines", orderLines)
    .Build();

await dbContext.ExecuteNonQueryAsync(sp, ct);

Caching

var sp = new StoredProcedureParametersBuilder("dbo", "sp_GetProducts", capacity: 2)
    .AddParameter("CategoryId", categoryId, SqlDbType.Int)
    .AddFrozenCache("products:all")                          // immutable, process-lifetime
    // .AddInMemoryCache("products:all", TimeSpan.FromMinutes(5))
    // .AddRedisCache("products:all", TimeSpan.FromMinutes(5))
    .Build();

Write Operations

var sp = new StoredProcedureParametersBuilder("dbo", "sp_CreateProduct", capacity: 2)
    .AddParameter("Name", name, SqlDbType.NVarChar)
    .AddParameter("Price", price, SqlDbType.Decimal)
    .Build();

await dbContext.ExecuteNonQueryAsync(sp, ct);

// Or retrieve a scalar return value
int newId = await dbContext.ExecuteScalarAsync<int>(sp, ct);

Multi-Result Sets

var sp = new StoredProcedureParametersBuilder("dbo", "sp_GetDashboard", capacity: 0).Build();

(IEnumerable<ProductDto> products, IEnumerable<CategoryDto> categories) =
    await dbContext.QueryMultipleIEnumerableAsync<ProductDto, CategoryDto>(sp, ct);

Supported up to 5 result sets: QueryMultipleIEnumerableAsync<T1,T2> through QueryMultipleIEnumerableAsync<T1,T2,T3,T4,T5>.

Available Query Methods

Method Returns
QueryAsReadOnlyCollectionAsync<T> IReadOnlyCollection<T>
QueryAsIEnumerableAsync<T> IEnumerable<T>
QueryAsImmutableArrayAsync<T> ImmutableArray<T>
FirstQueryAsync<T> T (first row)
ExecuteNonQueryAsync void
ExecuteAsync void
ExecuteScalarAsync<T> T

Documentation

Full documentation, samples, and API reference: https://caerius.net

Source code & releases: https://github.com/CaeriusNET/CaeriusNet

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
11.0.1 45 4/21/2026
11.0.0 83 4/20/2026
10.3.0 84 4/19/2026
10.2.1 80 4/19/2026
10.1.3 115 2/20/2026
10.1.2 264 1/22/2026
10.1.0 252 12/19/2025
10.0.1 203 12/5/2025
10.0.0.8-alpha 169 11/2/2025
10.0.0.7-alpha 169 10/29/2025
10.0.0.6-alpha 163 10/29/2025
10.0.0.5-alpha 174 10/29/2025
10.0.0.4-alpha 168 10/28/2025
10.0.0.3-alpha 160 10/28/2025
10.0.0.2-alpha 166 10/27/2025
10.0.0.1-alpha 112 10/25/2025
10.0.0 309 11/12/2025
10.0.0-alpha 244 10/21/2025 10.0.0-alpha is deprecated because it is no longer maintained and has critical bugs.
9.4.1 233 9/5/2025
9.4.0 316 9/3/2025 9.4.0 is deprecated because it is no longer maintained and has critical bugs.
Loading failed