Skip to content

What is CaeriusNet?

CaeriusNet is a focused data-access package for C# 14, .NET 10, and SQL Server stored procedures. It helps you call stored procedures, map result sets to strongly typed DTOs, pass table-valued parameters, cache read results, and observe database calls with tracing and metrics.

CaeriusNet is intentionally narrow. It does not translate LINQ, track entities, create migrations, or generate SQL text. You keep SQL Server and stored procedures as the contract. CaeriusNet provides the .NET API around that contract.

Package scope

Use CaeriusNet when your application owns or consumes SQL Server stored procedures. Use a full ORM when you need change tracking, LINQ query translation, migrations, or database-provider portability.

Why use CaeriusNet?

CaeriusNet is designed for teams that want stable SQL contracts and low-overhead .NET call sites.

CapabilityBenefit
Stored procedure callsKeeps SQL logic in SQL Server and makes the .NET call site explicit.
DTO mappingConverts each row into a typed C# DTO with ordinal column reads.
Source generatorsRemoves repetitive DTO and TVP mapper code while preserving compile-time checks.
Table-valued parametersSends large sets of IDs, GUIDs, or composite values without building DataTable objects.
Multiple result setsReads related result sets from a single database round trip.
Per-call cachingApplies Frozen, in-memory, or Redis caching only where the call is safe to cache.
TransactionsProvides explicit async transaction scopes with commit, rollback, and automatic rollback on dispose.
ObservabilityEmits tracing, metrics, and structured logs for stored procedure execution.

What CaeriusNet does

Use CaeriusNet to:

  • Execute stored procedures through ICaeriusNetDbContext.
  • Build stored procedure inputs with StoredProcedureParametersBuilder.
  • Read one row with FirstQueryAsync<T>().
  • Materialize result sets as IEnumerable<T>, ReadOnlyCollection<T>, or ImmutableArray<T>.
  • Execute writes with ExecuteNonQueryAsync, ExecuteScalarAsync<T>, or ExecuteAsync.
  • Pass TVPs through AddTvpParameter.
  • Read two to five result sets with QueryMultiple*Async.
  • Configure caching on individual read calls.
  • Run multiple commands in an ICaeriusNetTransaction.

What CaeriusNet does not do

CaeriusNet does not:

  • Translate LINQ expressions to SQL.
  • Track entities or detect changes.
  • Generate database migrations.
  • Build ad hoc SQL strings.
  • Target multiple database providers.
  • Replace SQL Server schema design, indexing, or query tuning.

This boundary is deliberate. It keeps the package small and predictable for applications that already use stored procedures as their data-access boundary.

How a read call works

A typical read has four parts:

  1. Create a DTO that implements ISpMapper<T> or use [GenerateDto].
  2. Build the stored procedure call with StoredProcedureParametersBuilder.
  3. Call a read method such as QueryAsReadOnlyCollectionAsync<T>().
  4. Receive a typed result collection.
csharp
[GenerateDto]
public sealed partial record UserDto(int Id, string Name, byte Age);

var sp = new StoredProcedureParametersBuilder("Users", "usp_Get_By_Age", 128)
    .AddParameter("Age", 18, SqlDbType.Int)
    .Build();

ReadOnlyCollection<UserDto> users =
    await dbContext.QueryAsReadOnlyCollectionAsync<UserDto>(sp, ct);

When to use each result shape

MethodUse when
FirstQueryAsync<T>The procedure returns zero or one row.
QueryAsIEnumerableAsync<T>You want a simple materialized sequence for LINQ operations.
QueryAsReadOnlyCollectionAsync<T>You expose results through public APIs that should not be mutated.
QueryAsImmutableArrayAsync<T>You want a compact immutable value for hot paths or cached data.
QueryMultiple*AsyncThe procedure returns related result sets that should be loaded together.

How it compares

FeatureCaeriusNetEF CoreDapper
Primary modelSQL Server stored proceduresLINQ and entity modelSQL text and ADO.NET commands
Change trackingNoYesNo
Database providersSQL ServerMultiple providersMultiple ADO.NET providers
DTO mappingStatic mapper contract or source generationEntity materializationRuntime mapping or manual mapping
TVP supportBuilt inManual setupManual setup
Multiple result setsTyped tuple APIsManual reader handlingQueryMultiple
Built-in cachingFrozen, in-memory, RedisExtension-basedNo
Tracing and metricsBuilt inExternal instrumentationExternal instrumentation

Released under the MIT License.