protected virtual async Task <bool?> ReadKeyExistenceAsync <TKey, TValue>(TKey elementKey, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (!initialized) { ThrowLazyInitializationExceptionIfNotConnected(); CollectionEntry entry = session.PersistenceContext.GetCollectionEntry(this); ICollectionPersister persister = entry.LoadedPersister; if (persister.IsExtraLazy) { var queueOperationTracker = (AbstractMapQueueOperationTracker <TKey, TValue>)GetOrCreateQueueOperationTracker(); if (queueOperationTracker == null) { if (HasQueuedOperations) { await(session.FlushAsync(cancellationToken)).ConfigureAwait(false); } return(persister.IndexExists(entry.LoadedKey, elementKey, session)); } if (queueOperationTracker.ContainsKey(elementKey)) { return(true); } if (queueOperationTracker.Cleared) { return(false); } if (queueOperationTracker.IsElementKeyQueuedForDelete(elementKey)) { return(false); } // As keys are unordered we don't have to calculate the current order of the key return(persister.IndexExists(entry.LoadedKey, elementKey, session)); } Read(); } return(null); }
protected virtual bool?ReadIndexExistence(object index) { if (!initialized) { ThrowLazyInitializationExceptionIfNotConnected(); CollectionEntry entry = session.PersistenceContext.GetCollectionEntry(this); ICollectionPersister persister = entry.LoadedPersister; if (persister.IsExtraLazy) { if (HasQueuedOperations) { session.Flush(); } return(persister.IndexExists(entry.LoadedKey, index, session)); } } Read(); return(null); }