public void Delete() { if (Categories.Any()) { throw new ArgumentOutOfRangeException("Category has descendants."); } if (Passwords.Any()) { throw new ArgumentOutOfRangeException("Category has associated Passwords."); } if (Parent != null) { Parent.Categories.Remove(this); Context.DeleteCategory(this); } }