Docs / MooDbContext Reference

MooDbContext Reference

Role#

MooDbContext is the main entry point for stored procedure execution, transactions, SQL text access, bulk loading, scalar reads, and result mapping.

Constructors#

</> C#
public MooDbContext(string connectionString, MooDbContextOptions? options = null)
public MooDbContext(SqlConnection connection, MooDbContextOptions? options = null)

Properties#

  • Sql : MooSql
  • Bulk : MooBulk

Main methods#

</> C#
Task<int> ExecuteAsync(...)
Task<T> ScalarAsync<T>(...)
Task<T?> SingleAsync<T>(...)
Task<T?> SingleAsync<T>(..., Func<SqlDataReader, T> map, ...)
Task<List<T>> ListAsync<T>(...)
Task<List<T>> ListAsync<T>(..., Func<SqlDataReader, T> map, ...)
Task<TResult> QueryMultipleAsync<TResult>(..., Func<IMooMultiReader, TResult> read, ...)
Task<MooTransaction> BeginTransactionAsync(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, ...)

Key points#

  • the main surface is stored procedure based
  • raw SQL goes through Sql
  • bulk loading goes through Bulk
  • transactions start here