Exemplo n.º 1
0
        public override void InitializeCollection(IPersistentCollection collection, bool writing)
        {
            if (temporaryPersistenceContext.IsLoadFinished)
            {
                throw new SessionException("Collections cannot be fetched by a stateless session. You can eager load it through specific query.");
            }
            CollectionEntry ce = temporaryPersistenceContext.GetCollectionEntry(collection);

            if (!collection.WasInitialized)
            {
                ce.LoadedPersister.Initialize(ce.LoadedKey, this);
            }
        }
Exemplo n.º 2
0
 public override Task InitializeCollectionAsync(IPersistentCollection collection, bool writing, CancellationToken cancellationToken)
 {
     if (temporaryPersistenceContext.IsLoadFinished)
     {
         throw new SessionException("Collections cannot be fetched by a stateless session. You can eager load it through specific query.");
     }
     if (cancellationToken.IsCancellationRequested)
     {
         return(Task.FromCanceled <object>(cancellationToken));
     }
     try
     {
         CollectionEntry ce = temporaryPersistenceContext.GetCollectionEntry(collection);
         if (!collection.WasInitialized)
         {
             return(ce.LoadedPersister.InitializeAsync(ce.LoadedKey, this, cancellationToken));
         }
         return(Task.CompletedTask);
     }
     catch (Exception ex)
     {
         return(Task.FromException <object>(ex));
     }
 }