Can my project without any root obj or root business list?

Can my project without any root obj or root business list?

Old forum URL: forums.lhotka.net/forums/t/10661.aspx


kingmoon posted on Saturday, September 03, 2011

Just mark all obj or collection as child but not root ?  Will it occur some problem

JonnyBee replied on Saturday, September 03, 2011

You cannot call Save() on a Child object and you cannon call BeginEdit, ApplyEdit, CancelEdit on editable collection that is marked as Child.

You could override the default Save method tho:

    public virtual T Save()
    {
      T result;
      if (this.IsChild)
        throw new InvalidOperationException(Resources.NoSaveChildException);
      if (EditLevel > 0)
        throw new InvalidOperationException(Resources.NoSaveEditingException);
      if (!IsValid && !IsDeleted)
        throw new Rules.ValidationException(Resources.NoSaveInvalidException);
      if (IsBusy)
        throw new InvalidOperationException(Resources.BusyObjectsMayNotBeSaved);
      if (IsDirty)
        result = (T)DataPortal.Update(this);
      else
        result = (T)this;
      OnSaved(result, nullnull);
      return result;
    }

kingmoon replied on Saturday, September 03, 2011

In my project, I want to create a XmlModelBase derive from BusinessBase and implement auto save and fetch from xml file. But I don't want to relize four suit code(a child obj , a root obj,  a child business list, a root business list ). Now I have implemented two suit for Child Business Obj and Child Business List Obj. Can I declare a root obj and all child obj's parent reference to this root obj.  

Copyright (c) Marimer LLC