Path: redb/redb.MSSql/Data/SqlRedbContext.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.MSSql/Data/SqlRedbContext.cs ---- using redb.Core.Data; namespace redb.MSSql.Data; /// /// MS SQL Server implementation of REDB context. /// Assembles all SQL Server components into single facade. /// public class SqlRedbContext : RedbContextBase { private readonly SqlRedbConnection _connection; private readonly SqlKeyGenerator _keyGenerator; private readonly SqlBulkOperations _bulkOperations; /// /// Database connection. /// public override IRedbConnection Db => _connection; /// /// Key generator with caching. /// public override IKeyGenerator Keys => _keyGenerator; /// /// Bulk operations (SqlBulkCopy). /// protected override IBulkOperations BulkOperations => _bulkOperations; /// protected override Task QueryRowsAsJsonCoreAsync(string sql, object[] parameters, System.Threading.CancellationToken cancellationToken) => _connection.QueryRowsAsJsonAsync(sql, parameters, cancellationToken); /// /// Connection string (for direct access if needed). /// public string ConnectionString { get; } /// /// Create SQL Server context from connection string. /// /// MS SQL Server connection string. public SqlRedbContext(string connectionString, bool lazyReferences = false) { if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString)); ConnectionString = connectionString; _connection = new SqlRedbConnection(connectionString, lazyReferences); var domain = redb.Core.Models.Configuration.RedbServiceConfiguration.ComputeCacheDomain(connectionString); _keyGenerator = new SqlKeyGenerator(connectionString, domain, scopeConnection: () => _connection); _bulkOperations = new SqlBulkOperations(_connection) { TimeoutSource = () => BulkInsertTimeout }; } /// /// Dispose context and all components. /// public override async ValueTask DisposeAsync() { await _connection.DisposeAsync(); } }