Raven.Client.Document.DocumentStore.OpenAsyncSession C# (CSharp) Method

OpenAsyncSession() public method

public OpenAsyncSession ( ) : IAsyncDocumentSession
return IAsyncDocumentSession
		public IAsyncDocumentSession OpenAsyncSession()
		{
			if (DatabaseCommands == null)
				throw new InvalidOperationException("You cannot open a session before initialising the document store. Did you forgot calling Initialise?");
			if (AsyncDatabaseCommands == null)
				throw new InvalidOperationException("You cannot open an async session because it is not supported on embedded mode");

			var session = new AsyncDocumentSession(this, storeListeners, deleteListeners);
			session.Stored += OnSessionStored;
			return session;
		}
#endif

Usage Example

Esempio n. 1
0
		public void AsyncLoad()
		{
			using (GetNewServer())
			using (var store = new DocumentStore
			{
				Url = "http://localhost:8079"
			}.Initialize())
			{
				using (var session = store.OpenAsyncSession())
				{
					session.Store(new Dummy() );

					session.SaveChangesAsync().Wait();
				}
				using (var session = store.OpenAsyncSession())
				{
					session.LoadAsync<Dummy>("dummies/1").Wait();
					Assert.Equal(0, store.JsonRequestFactory.NumberOfCachedRequests);
				}
				using (var session = store.OpenAsyncSession())
				{
					session.LoadAsync<Dummy>("dummies/1").Wait();
					Assert.Equal(1, store.JsonRequestFactory.NumberOfCachedRequests);
				}
			}
		}
All Usage Examples Of Raven.Client.Document.DocumentStore::OpenAsyncSession