protected IDataSession CreateSession(string databaseName) { IDataSessionManager manager = Resolve <IDataSessionManager>(); if (manager == null) { throw new InvalidOperationException("DataSessionManager not registered"); } return(manager.CreateSession(databaseName)); }
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); } } } }
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(); } } } }