public TEntity GetById(int id) { var currentSession = OpenSession ?? ActiveSessionManager.GetActiveSession(); var returnObject = currentSession.Get <TEntity>(id); return(returnObject); }
public void BeginTransaction() { if (_transaction != null) { throw new InvalidOperationException("Transaction already started; nested transactions are not supported."); } _transaction = _activeSessionManager.GetActiveSession().BeginTransaction(); }
public UnitOfWork(IActiveSessionManager sessionManager) { this.sessionManager = sessionManager; if (sessionManager.HasActiveSession) { isRootUnitOfWork = false; session = sessionManager.GetActiveSession(); } else { isRootUnitOfWork = true; session = sessionManager.OpenSession(); } }
/// <summary> /// /// </summary> /// <param name="sessionManager"></param> public UnitOfWork(IActiveSessionManager sessionManager) { _session = sessionManager.GetActiveSession(); //this may be an already open session... _session.FlushMode = FlushMode.Auto; //default }