public override void Persist(Context context) { bool NeedUpdate = this.ID == 0; base.Persist(context); foreach (OrgUnit branch in OrgUnits) { branch.OrganizationParent = this; branch.Persist(context); } foreach (User e in this.Users) { e.Persist(context); } if (ContactName != null) { ContactName.Persist(context); } if (NeedUpdate) { context.PersistenceSession.Update(this); } }