Exemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Exemplo n.º 2
0
        //#region transaction
        //private DbContextTransaction transaction { get; set; }

        //public void BeginTransAction()
        //{
        //    if (transaction != null)
        //    {
        //        throw new Exception("another transaction already exist!");
        //    }
        //    transaction = _db.Database.BeginTransaction();
        //}

        //public void BeginTransAction(System.Data.IsolationLevel transLevel)
        //{
        //    if (transaction != null)
        //    {
        //        throw new Exception("another transaction already exist!");
        //    }
        //    transaction = _db.Database.BeginTransaction(transLevel);
        //}

        //public void Rollback()
        //{
        //    if (transaction != null)
        //    {
        //        transaction.Rollback();
        //        transaction.Dispose();
        //        transaction = null;
        //    }
        //    else
        //    {
        //        throw new Exception("no transaction exist!");
        //    }
        //}

        //public void Commit()
        //{
        //    if (transaction != null)
        //    {
        //        transaction.Commit();
        //        transaction.Dispose();
        //        transaction = null;
        //    }
        //    else
        //    {
        //        throw new Exception("no transaction exist!");
        //    }
        //}
        //#endregion

        public void Dispose()
        {
            _db.Dispose();
        }