/// <summary> Delete any entities that were removed from the collection</summary> private async Task DeleteOrphansAsync(string entityName, IPersistentCollection pc, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); //TODO: suck this logic into the collection! ICollection orphans; if (pc.WasInitialized) { CollectionEntry ce = eventSource.PersistenceContext.GetCollectionEntry(pc); orphans = ce == null ? CollectionHelper.EmptyCollection : ce.GetOrphans(entityName, pc); } else { orphans = pc.GetQueuedOrphans(entityName); } foreach (object orphan in orphans) { if (orphan != null) { log.Info("deleting orphaned entity instance: {0}", entityName); await(eventSource.DeleteAsync(entityName, orphan, false, null, cancellationToken)).ConfigureAwait(false); } } }
/// <summary> Delete any entities that were removed from the collection</summary> private void DeleteOrphans(string entityName, IPersistentCollection pc) { //TODO: suck this logic into the collection! ICollection orphans; if (pc.WasInitialized) { CollectionEntry ce = eventSource.PersistenceContext.GetCollectionEntry(pc); orphans = ce == null ? CollectionHelper.EmptyCollection : ce.GetOrphans(entityName, pc); } else { orphans = pc.GetQueuedOrphans(entityName); } foreach (object orphan in orphans) { if (orphan != null) { log.Info("deleting orphaned entity instance: " + entityName); eventSource.Delete(entityName, orphan, false, null); } } }