The code that is needed comes below:
public static void Delete(int specificationId)
{
var db = new WebEntities(); // Your entity framework context object
var spec = db.Specifications.Where(item => item.Id == specificationId).FirstOrDefault();
if (spec == null) return;
db.Specifications.Remove(spec);
db.SaveChanges();
}
The same thing needs to be done for the relation between SpecificationHeader and SpecificationItem, but I hope you can manage that on your own.
Save all changes to your Entity Model and normally you should be able to use cascading deletions only by applying the Remove method to the parent Specification object.
No comments:
Post a Comment