コード例 #1
0
ファイル: DALFacade.cs プロジェクト: akiker/CV2
 public void DisposeUnitOfWork()
 {
     if (_unitOfWork != null)
     {
         //If we do not own the connection, it should be already closed
         if (!KeepConnectionAlive)
         {
             if (_dbConnection != null)
                 throw new Exception("Database connection is not null in disconnected state.");
         }
         else if (_dbConnection == null || _dbConnection.State != ConnectionState.Open)
             throw new Exception("Database connection is not open in connected state.");
         _unitOfWork.Dispose();
         _unitOfWork = null;
         _context = null;
     }
 }
コード例 #2
0
ファイル: DALFacade.cs プロジェクト: akiker/CV2
 /// <summary>
 ///     Used to initialize the database preemptively on first run.
 /// </summary>
 /// <summary>
 ///     Creates and returns a unit of work to the caller.
 ///     If a unit of work is already being used then it throws an exception.
 ///     Allows only one instance of unit of work to exists.
 /// </summary>
 /// <returns></returns>
 public IUnitOfWork GetUnitOfWork()
 {
     if (_unitOfWork != null)
         throw new Exception("A unit of work is already in use.");
     _context = new Cv2Context();
     _unitOfWork = new UnitOfWork(_context);
     return _unitOfWork;
 }