Esempio n. 1
0
        protected IDataSession CreateSession(string databaseName)
        {
            IDataSessionManager manager = Resolve <IDataSessionManager>();

            if (manager == null)
            {
                throw new InvalidOperationException("DataSessionManager not registered");
            }

            return(manager.CreateSession(databaseName));
        }
Esempio n. 2
0
        protected T DoInTransaction <T>(Block <T> block)
        {
            IDataSessionManager sessionManager = Resolve <IDataSessionManager>();

            using (IDataSession session = sessionManager.CreateSession(DatabaseName))
            {
                using (IDataConnection connection = session.OpenConnection())
                {
                    using (ITransaction transaction = connection.BeginTransaction())
                    {
                        OnBeginTransaction(session);

                        T value = block();

                        transaction.Commit();

                        return(value);
                    }
                }
            }
        }
Esempio n. 3
0
        protected T DoInSession <T>(Block <T> block)
        {
            IDataSessionManager sessionManager = Resolve <IDataSessionManager>();

            using (IDataSession session = sessionManager.CreateSession(DatabaseName))
            {
                IDataConnection connection = null;

                try
                {
                    connection = session.OpenConnection();

                    return(block());
                }
                finally
                {
                    if (connection != null)
                    {
                        connection.Dispose();
                    }
                }
            }
        }