Core Concepts — UnitOfWork, Savepoints, MultiMap & SqlEntity
L3StableNuGet: v2.0.0Local HEAD: v3.1.0AOT: Full
EricksonLopez.DapperExtensions models database transactions, nested savepoints, resilience retries, and AOT-safe multi-mapping as explicit contracts.
Unit of Work & Savepoints (IUnitOfWork, ISavepoint)
Section titled “Unit of Work & Savepoints (IUnitOfWork, ISavepoint)”BeginUnitOfWorkAsync(IsolationLevel, CancellationToken): Opens the connection if closed (closing it on dispose only whenownsConnectionistrue) and begins an ADO.NETDbTransaction.WithUnitOfWorkAsync(...): Executes an asynchronous delegate, commits automatically if no exception escapes, and rolls back on failure.CreateSavepointAsync(string name): Requires an underlyingSystem.Data.Common.DbTransaction(throwingNotSupportedExceptionon rawIDbTransactionmocks withoutDbTransactionperBC-001) and returns anISavepointsupportingRollbackAsyncandReleaseAsync.
Resilience Pipelines (SqlResilienceDefaults)
Section titled “Resilience Pipelines (SqlResilienceDefaults)”EricksonLopez.DapperExtensions.Resilience provides pre-configured pipelines built on EricksonLopez.Resilience and Polly:
SqlResilienceDefaults.ForPostgreSqlPipeline()/ForPostgreSqlWithCircuitBreakerPipeline()SqlResilienceDefaults.ForSqlServerPipeline()/ForSqlServerWithCircuitBreakerPipeline()SqlResilienceExtensions.ExecuteWithResilienceAsyncandQueryWithResilienceAsync<T>SavepointResilienceExtensions.ExecuteInSavepointWithRetryAsyncfor retriable nested operations inside an openIUnitOfWork.
Zero-Reflection [SqlEntity] & MultiMapBuilder<TReturn>
Section titled “Zero-Reflection [SqlEntity] & MultiMapBuilder<TReturn>”- Annotate
partialclasses with[SqlEntity(TableName = "orders")]and referenceEricksonLopez.DapperExtensions.SourceGeneratorsto generateReadFromDataReaderandGetMultiMapReaderFactoryat compile time. - Use
MultiMapBuilder<TReturn>.Query(ISqlQuery).Map<T>(splitOn, combiner).QueryGroupedAsync<TKey>(...)to hydrate parent-child aggregates without reflection. - AOT Caveat (
ADR-019):DapperStreamingExtensions.StreamAsync<T>uses Dapper’s reflection-basedGetRowParser<T>and is not suitable for reflection-free Native AOT paths; prefer[SqlEntity]generated mappers for AOT hosts.