/// <summary> /// Determine if the collection is "really" dirty, by checking dirtiness /// of the collection elements, if necessary /// </summary> private async Task DirtyAsync(IPersistentCollection collection, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); // if the collection is initialized and it was previously persistent // initialize the dirty flag bool forceDirty = collection.WasInitialized && !collection.IsDirty && LoadedPersister != null && LoadedPersister.IsMutable && (collection.IsDirectlyAccessible || LoadedPersister.ElementType.IsMutable) && !await(collection.EqualsSnapshotAsync(LoadedPersister, cancellationToken)).ConfigureAwait(false); if (forceDirty) { collection.Dirty(); } }