Beispiel #1
0
 public Repository(IUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _context    = _unitOfWork.Context;
     // Create objectset to work with.
     if (_unitOfWork != null && _context != null)
     {
         _dbSet = _context.Set <TEntity>();
     }
 }
Beispiel #2
0
        public virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                // free other managed objects that implement
                // IDisposable only

                try
                {
                    if (_context != null && _context.Database.Connection.State == ConnectionState.Open)
                    {
                        _context.Database.Connection.Close();
                    }
                }
                catch (ObjectDisposedException)
                {
                    // do nothing, the objectContext has already been disposed
                }

                if (_context != null)
                {
                    _context.Dispose();
                    _context = null;
                }
            }

            // release any unmanaged objects
            // set the object references to null

            _disposed = true;
        }
Beispiel #3
0
 public UnitOfWork(ErpdbEntities context)
 {
     this._context = context;
 }