/// <summary>
        /// Adds a asynchronous session that uses the specified server and database.
        /// </summary>
        /// <param name="connection">The class containing all the information needed to find the correct server and establish the session.</param>
        /// <returns>The <see cref="RavenBuilder"/> this method is contained in.</returns>
        public RavenBuilder AddAsyncSession(
            RavenConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            Services.AddScoped <IAsyncDocumentSession, IAsyncDocumentSession>(provider =>
            {
                var manager = provider
                              .GetService <IRavenManager>();

                return(manager.GetAsyncSession(connection));
            });

            return(this);
        }
        /// <summary>
        /// Gets a session that uses the specified server and database.
        /// </summary>
        /// <param name="connection">The class containing all the information needed to find the correct server and establish the session.</param>
        /// <returns>The specified Session.</returns>
        public IDocumentSession GetSession(
            RavenConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            var store = GetStore(connection.Server);

            if (connection.Database == null)
            {
                return(store.OpenSession());
            }
            else
            {
                return(store.OpenSession(connection.Database));
            }
        }