Пример #1
0
        /// <summary>
        /// Opens the session for a particular database with the specified credentials
        /// </summary>
        public IDocumentSession OpenSession(string database, ICredentials credentialsForSession)
        {
            EnsureNotClosed();

            var sessionId = Guid.NewGuid();

            currentSessionId = sessionId;
            try
            {
                var session = new DocumentSession(this, listeners, sessionId, DatabaseCommands
                                                  .ForDatabase(database)
                                                  .With(credentialsForSession)
#if !NET_3_5
                                                  , AsyncDatabaseCommands
                                                  .ForDatabase(database)
                                                  .With(credentialsForSession)
#endif
                                                  );
                AfterSessionCreated(session);
                return(session);
            }
            finally
            {
                currentSessionId = null;
            }
        }
Пример #2
0
        /// <summary>
        /// Opens the session for a particular database
        /// </summary>
        public IDocumentSession OpenSession(string database)
        {
            var session = new DocumentSession(this, queryListeners, storeListeners, deleteListeners, DatabaseCommands.ForDatabase(database)
#if !NET_3_5
                                              , AsyncDatabaseCommands.ForDatabase(database)
#endif
                                              );

            AfterSessionCreated(session);
            return(session);
        }
Пример #3
0
        /// <summary>
        /// Opens the async session.
        /// </summary>
        /// <returns></returns>
        public IAsyncDocumentSession OpenAsyncSession(string databaseName)
        {
            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, AsyncDatabaseCommands.ForDatabase(databaseName), queryListeners, storeListeners, deleteListeners);

            session.Stored += OnSessionStored;
            return(session);
        }
Пример #4
0
        /// <summary>
        /// Opens the async session.
        /// </summary>
        /// <returns></returns>
        public IAsyncDocumentSession OpenAsyncSession(string databaseName)
        {
            EnsureNotClosed();

            var sessionId = Guid.NewGuid();

            currentSessionId = sessionId;
            try
            {
                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, AsyncDatabaseCommands.ForDatabase(databaseName), listeners, sessionId);
                AfterSessionCreated(session);
                return(session);
            }
            finally
            {
                currentSessionId = null;
            }
        }
Пример #5
0
 /// <summary>
 /// Opens the async session.
 /// </summary>
 /// <returns></returns>
 public override IAsyncDocumentSession OpenAsyncSession(string databaseName)
 {
     return(OpenAsyncSessionInternal(AsyncDatabaseCommands.ForDatabase(databaseName)));
 }