示例#1
0
        public TEntity GetById(int id)
        {
            var currentSession = OpenSession ?? ActiveSessionManager.GetActiveSession();

            var returnObject = currentSession.Get <TEntity>(id);

            return(returnObject);
        }
示例#2
0
        public void BeginTransaction()
        {
            if (_transaction != null)
            {
                throw new InvalidOperationException("Transaction already started; nested transactions are not supported.");
            }

            _transaction = _activeSessionManager.GetActiveSession().BeginTransaction();
        }
示例#3
0
        public UnitOfWork(IActiveSessionManager sessionManager)
        {
            this.sessionManager = sessionManager;

            if (sessionManager.HasActiveSession)
            {
                isRootUnitOfWork = false;
                session          = sessionManager.GetActiveSession();
            }
            else
            {
                isRootUnitOfWork = true;
                session          = sessionManager.OpenSession();
            }
        }
示例#4
0
 /// <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
 }