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

OpenSession() public method

public OpenSession ( ) : IDocumentSession
return IDocumentSession
		public IDocumentSession OpenSession()
        {
            if(DatabaseCommands == null)
                throw new InvalidOperationException("You cannot open a session before initialising the document store. Did you forgot calling Initialise?");
            var session = new DocumentSession(this, storeListeners, deleteListeners);
			session.Stored += OnSessionStored;
            return session;
        }

Same methods

DocumentStore::OpenSession ( ICredentials credentialsForSession ) : IDocumentSession

Usage Example

Esempio n. 1
0
		public void CanProfileLazyRequests()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" })
			{
				store.Initialize();
				store.InitializeProfiling();
				using (var session = store.OpenSession())
				{
					// handle the initial request for replication information
				}
				Guid id;
				using (var session = store.OpenSession())
				{
					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
					session.Advanced.Lazily.Load<User>("users/1");
					session.Advanced.Lazily.Load<User>("users/2");
					session.Advanced.Lazily.Load<User>("users/3");

					session.Advanced.Eagerly.ExecuteAllPendingLazyOperations();
				}

				var profilingInformation = store.GetProfilingInformationFor(id);
				Assert.Equal(1, profilingInformation.Requests.Count);

				var responses = JsonConvert.DeserializeObject<GetResponse[]>(profilingInformation.Requests[0].Result, Default.Converters);
				Assert.Equal(3, responses.Length);
				foreach (var response in responses)
				{
					Assert.Equal(404, response.Status);
				}

			}
		}
All Usage Examples Of Raven.Client.Document.DocumentStore::OpenSession