public static void Delete(LookupGreenTemplate lookupGreenTemplate) { using (IObjectRepository tdb = DBContext.Create()) { GreenTemplate greenTemplate = tdb.GreenTemplates.Single(y => y.Id == lookupGreenTemplate.Id); // Remove all green constraints associated with the green template greenTemplate.ChildGreenConstraints.ToList().ForEach(y => tdb.GreenConstraints.DeleteObject(y)); // Remove the green template tdb.GreenTemplates.DeleteObject(greenTemplate); tdb.SaveChanges(); } }
public static void Delete(LookupGreenTemplate lookupGreenTemplate) { using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource()) { GreenTemplate greenTemplate = tdb.GreenTemplates.Single(y => y.Id == lookupGreenTemplate.Id); // Remove all green constraints associated with the green template greenTemplate.ChildGreenConstraints.ToList().ForEach(y => tdb.GreenConstraints.DeleteObject(y)); // Remove the green template tdb.GreenTemplates.DeleteObject(greenTemplate); tdb.SaveChanges(); } }