Path: redb/redb.Core/Exceptions/RedbLazyLoadScopeEndedException.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/Exceptions/RedbLazyLoadScopeEndedException.cs ---- using System; namespace redb.Core.Exceptions; /// /// Thrown when a lazy load - the Props of an unloaded reference, RedbListItem.Object - finds no live redb /// scope to run on. A data object owns no connection: the load runs on the scope of whoever reads it (owner decision /// 2026-09-15). Here none reads: the scope that loaded the object has ended, or the code runs outside any scope - a /// background task, a static cache, a UI event handler. Before, the load quietly took a fresh scope and pooled connection /// per read. /// public class RedbLazyLoadScopeEndedException : InvalidOperationException { private const string WaysOut = " Read it inside a live scope: resolve IRedbService from a scope, or wrap the block in " + "using (redb.BeginAccess()) { ... } (UI event handlers, background work). Or load it explicitly while a scope " + "is alive - redb.LoadAsync(id), redb.LoadReferencesAsync(parent, p => p.Reference), redb.LoadLinkedObjectsAsync(items), " + "a larger depth - or set RedbServiceConfiguration.LazyLoadWithoutScope = FreshScope to open a scope per load."; /// Id of the object whose Props (or which, behind a list item) were asked for. public long ObjectId { get; } /// Scheme of that object; 0 when the load came from a list item and the scheme is not known yet. public long SchemeId { get; } public RedbLazyLoadScopeEndedException(long objectId, long schemeId) : base($"Object {objectId} (scheme {schemeId}) is an unloaded reference and no live redb scope reads it here." + WaysOut) { ObjectId = objectId; SchemeId = schemeId; } private RedbLazyLoadScopeEndedException(string message, long objectId) : base(message) { ObjectId = objectId; } /// A list item's linked object asked for with no live redb scope. public static RedbLazyLoadScopeEndedException ForListItem(long listItemId, long objectId) => new($"The object {objectId} linked to list item {listItemId} is loaded lazily and no live redb scope reads it here." + WaysOut, objectId); }