示例#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
        public override IDocumentSession OpenSession(OpenSessionOptions options)
        {
            EnsureNotClosed();

            var sessionId = Guid.NewGuid();

            currentSessionId = sessionId;
            try
            {
                var session = new DocumentSession(this, listeners, sessionId,
                                                  SetupCommands(DatabaseCommands, options.Database, options.Credentials, options)
#if !NET35
                                                  , SetupCommandsAsync(AsyncDatabaseCommands, options.Database, options.Credentials, options)
#endif
                                                  )
                {
                    DatabaseName = options.Database
                };
                AfterSessionCreated(session);
                return(session);
            }
            finally
            {
                currentSessionId = null;
            }
        }
示例#3
0
 private void AfterSessionCreated(DocumentSession session)
 {
     session.Stored += OnSessionStored;
     foreach (var documentConvertionListener in conversionListeners)
     {
         session.Advanced.OnDocumentConverted += documentConvertionListener.DocumentToEntity;
         session.Advanced.OnEntityConverted   += documentConvertionListener.EntityToDocument;
     }
 }
示例#4
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);
        }
示例#5
0
        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);
        }
示例#6
0
        /// <summary>
        /// Opens the session with the specified credentials.
        /// </summary>
        /// <param name="credentialsForSession">The credentials for session.</param>
        public IDocumentSession OpenSession(ICredentials credentialsForSession)
        {
            var session = new DocumentSession(this, queryListeners, storeListeners, deleteListeners, DatabaseCommands.With(credentialsForSession)
#if !NET_3_5
                                              , AsyncDatabaseCommands.With(credentialsForSession)
#endif
                                              );

            AfterSessionCreated(session);
            return(session);
        }
示例#7
0
        public IDocumentSession OpenSession(string database, ICredentials credentialsForSession)
        {
            this.EnsureNotClosed();
            Guid id = Guid.NewGuid();

            DocumentStore.currentSessionId = new Guid?(id);
            try
            {
                DocumentSession documentSession = new DocumentSession(this, this.listeners, id, this.DatabaseCommands.ForDatabase(database).With(credentialsForSession), this.AsyncDatabaseCommands.ForDatabase(database).With(credentialsForSession));
                this.AfterSessionCreated((InMemoryDocumentSessionOperations)documentSession);
                return((IDocumentSession)documentSession);
            }
            finally
            {
                DocumentStore.currentSessionId = new Guid?();
            }
        }
示例#8
0
        public IDocumentSession OpenSession()
        {
            this.EnsureNotClosed();
            Guid id = Guid.NewGuid();

            DocumentStore.currentSessionId = new Guid?(id);
            try
            {
                DocumentSession documentSession = new DocumentSession(this, this.listeners, id, this.DatabaseCommands, this.AsyncDatabaseCommands);
                this.AfterSessionCreated((InMemoryDocumentSessionOperations)documentSession);
                return((IDocumentSession)documentSession);
            }
            finally
            {
                DocumentStore.currentSessionId = new Guid?();
            }
        }
示例#9
0
        public IDocumentSession OpenSession(ICredentials credentialsForSession)
        {
            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, DatabaseCommands.With(credentialsForSession));

            session.Stored += entity =>
            {
                var copy = Stored;
                if (copy != null)
                {
                    copy(Identifier, entity);
                }
            };
            return(session);
        }
示例#10
0
        public override IDocumentSession OpenSession(OpenSessionOptions options)
        {
            EnsureNotClosed();

            var sessionId = Guid.NewGuid();

            currentSessionId = sessionId;
            try
            {
                var databaseName = options.Database ?? DefaultDatabase ?? MultiDatabase.GetDatabaseName(Url);
                var session      = new DocumentSession(databaseName, this, Listeners, sessionId,
                                                       SetupCommands(DatabaseCommands, databaseName, options.Credentials, options));
                AfterSessionCreated(session);
                return(session);
            }
            finally
            {
                currentSessionId = null;
            }
        }
示例#11
0
        /// <summary>
        /// Opens the session.
        /// </summary>
        /// <returns></returns>
        public IDocumentSession OpenSession()
        {
            EnsureNotClosed();

            var sessionId = Guid.NewGuid();

            currentSessionId = sessionId;
            try
            {
                var session = new DocumentSession(this, listeners, sessionId, DatabaseCommands
#if !NET_3_5
                                                  , AsyncDatabaseCommands
#endif
                                                  );
                AfterSessionCreated(session);
                return(session);
            }
            finally
            {
                currentSessionId = null;
            }
        }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiLoaderWithInclude{T}"/> class.
 /// </summary>
 /// <param name="session">The session.</param>
 public MultiLoaderWithInclude(DocumentSession session)
 {
     this.session = session;
 }
示例#13
0
 public DocumentQuery(DocumentSession session, IDatabaseCommands databaseCommands, string indexName, string[] projectionFields) : base(session)
 {
     this.databaseCommands = databaseCommands;
     this.projectionFields = projectionFields;
     this.indexName        = indexName;
 }
示例#14
0
 protected AbstractDocumentQuery(DocumentSession session)
 {
     this.session = session;
 }