Path: redb/redb.Core/IRedbScopeSource.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.Core/IRedbScopeSource.cs
----
using System;
namespace redb.Core;
///
/// A service that opens scopes of the container it came from: for code that holds one service and needs another of
/// the same database per unit of work - a parallel flow, a background job, an audit written outside any request.
/// One is one connection, so parallel work needs a service each; a service resolved from
/// the root provider lends its lazy loads a scope the same way (review after 4.0.0, finding 4). A service built
/// without a container has nothing to open a scope from ().
///
public interface IRedbScopeSource
{
/// Whether can open a scope: the service came from a container with a scope factory.
bool CanCreateScope { get; }
///
/// Opens a scope of the service's container and returns its service of the same database; the holder owns the
/// scope and disposes it when the unit of work ends. Throws when there is
/// no container ( is false), or when the scope's service reads another database - a
/// container that registers differently per resolution.
///
RedbScope CreateScope();
}