StrataFrame Forum

BO.Save and BO.SaveByForm

http://forum.strataframe.net/Topic20402.aspx

By Chan - 10/28/2008

Hi,

May I know when should I use BO.Save() and when should I use BO.SaveByForm()? I found that BO.SaveByForm() will return more info such as exception which should be more prefered. However, in most sample, BO.Save() is used.



Please advice.



Thank you
By Trent L. Taylor - 10/30/2008

It really depends on what are trying to accomplish.  The BO.Save() is ultimately called by the SaveByForm or Save() method of a form.  The only difference is that when a SaveByForm (Save() of the form) is called, it will attempt to save all BOs and respect the IncludeInForm properties as well as gather up all of the exceptions and broken rules for all BOs versus just each individual BO.
By Chan - 10/30/2008

Hi,

Thank you for reply.

When I compare source code for both methods (Bo.Save() vs Bo.SaveByForm()) they are almost the same, except Bo.SaveByForm() return value contains more info.



In my case, I am writing save function for my base Gridview and WebPage. I feel that SaveByForm() is more suitable as more info usually always better.



By then, I am curious on in what situation I should use Bo.Save() instead of Bo.SaveByForm()?



Thank you
By Trent L. Taylor - 10/30/2008

Honestly, in this case, I would probably just call the save on the BO.  The information is irrelevant if it is not pertinent to the BO at hand being saved.  Each individual BO will provide all of the same information as the SaveByForm.  The reason that the SaveByForm appears to have more detail is because it includes information for all BOs versus just the BO in question.

Calling an individual BO in this case would probably be the route that I would take.