BeginSave no works

BeginSave no works

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


ddredstar posted on Sunday, February 13, 2011

Has anybody ever encountered that BeginSave() not call DataPortal_Insert()?

Please help me,Thanks!

JonnyBee replied on Monday, February 14, 2011

BeginSave may call:

If <bo>.IsDeleted call DataPortal_DeleteSelf
else If <bo>.IsNew call DataPortal_Insert
         else call DataPortal_Update

So - which method is called depends on the state of your object.

ddredstar replied on Tuesday, February 15, 2011

I 'm sure that my Ojbect.IsNew is true, Why the DataPortal_Insert not be called?

JonnyBee replied on Tuesday, February 15, 2011

Is the objects IsDirty and IsSavable both true?

 

ddredstar replied on Tuesday, February 15, 2011

Both IsDirty and IsSavable are true.

JonnyBee replied on Wednesday, February 16, 2011

Add Csla projects to your solution and debug into the csla code:

Possible reasons:

In the BusinessBase.Save method (If IsDirty is false then object is returned) :

      if (IsDirty)
        result = (T)DataPortal.Update(this);
      else
        result = (T)this;

Save might throw an exception (If this is just "swallowed")

      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);

(Save may also throw DataPortalException if serverside code fails).

Serverside code follows the outline in my first post.

 

Copyright (c) Marimer LLC