protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (_context != null) { _context.Dispose(); } disposedValue = true; } }
public void Dispose() { if (_inventoryContext != null) { _inventoryContext.Dispose(); } }
protected virtual void Dispose(bool disposing) { // Cleanup if (_context != null) { _context.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing) { inventoryContext.Dispose(); } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public string AddUpdateProduct(Product model) { if (model.ProductID == -1) // new product { TB_Products aProduct = new TB_Products { ProductName = model.ProductName, CategoryID = model.CategoryID, UnitName = model.UnitName, Barcode = model.Barcode, Brand = model.Brand, IsActive = model.IsActive, Model = model.Model, Description = model.Description }; _context.TB_Products.Add(aProduct); } else // update product { var aProduct = _context.TB_Products.Find(model.ProductID); aProduct.ProductName = model.ProductName; aProduct.CategoryID = model.CategoryID; aProduct.UnitName = model.UnitName; aProduct.Barcode = model.Barcode; aProduct.Brand = model.Brand; aProduct.IsActive = model.IsActive; aProduct.Model = model.Model; aProduct.Description = model.Description; } try { _context.SaveChanges(); _context.Dispose(); return(""); } catch (Exception ex) { return(ex.Message); } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { _context.Dispose(); } } this.disposed = true; }
public virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { context.Dispose(); } this.disposed = true; } }
public void SelectUsers() { var Inventory = new InventoryContext(); try { var t1 = Inventory.Users.Where(user => user.StatusUser != null) .Where(u => u.StatusUser.IdStatusUser != 4).Where(u1 => u1.NameUser == "Яшина Полина Денисовна").ToArray(); TT(ref t1); } catch (Exception e) { Console.WriteLine(e); throw; } Inventory?.Dispose(); }
public ActionResult Edit([Bind(Include = "ID,Name,Description,Sku,Qty,Price,IsActive")] Inventory inventory) { //Creating a second connection to eliminate any collision with the first database connection var store = 0; using (InventoryContext context = new InventoryContext()) { store = context.Inventories.Where(x => x.ID == inventory.ID).FirstOrDefault().Stores.ID; context.Dispose();//forces new connection to close } if (ModelState.IsValid) { db.Entry(inventory).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); } return(RedirectToAction("Index", new { storeId = store })); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> public void Dispose() { _dbContext.Dispose(); }
public void Dispose() { _inventoryContext.Dispose(); }
public void Rollback() { _inventoryContext.Dispose(); }
//allows the use of using(UnitOfWork){} //saves changes to database before it is disposed public void Dispose() { Context.SaveChanges(); Context.Dispose(); }
public void Dispose() { _DB.Dispose(); }
public void Dispose() { _context.Dispose(); }
public static void Flush(this InventoryContext inventoryContext) { inventoryContext.Database.EnsureDeleted(); inventoryContext.Dispose(); }