private void Delete_Recur(DBFrontEnd db, GroupProduct gp) { List <GroupProduct> ListGroupProduct = gp.GroupProductChildrens.ToList(); if (ListGroupProduct != null) { foreach (var i in ListGroupProduct) { Delete_Recur(db, i); } } List <Product> ListProduct = gp.Products.ToList(); if (ListProduct != null) { foreach (var i in ListProduct) { db.Products.Remove(i); } db.SaveChanges(); } db.GroupProducts.Remove(gp); db.SaveChanges(); }