IsDirty = true, IsValid = true but IsSavable = false

IsDirty = true, IsValid = true but IsSavable = false

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


Dane posted on Sunday, December 18, 2011

I feel like I'm missing something in the initialization of the object in its DataPortal_Fetch but I'm not sure what.  The object in question inherits from BusinessBase.  I'm fetching an object in a console app and then editing one property.  After the edit IsDirty = true, IsValid = true but the object is not savable.  What am I missing?

Thanks for any input you might have,

Dane R. Vinson

JonnyBee replied on Sunday, December 18, 2011

Hi,

1. Does your object have async rules (still running or do not call context.Complete, ie: object is still IsBusy)

2. Does your object have any authorization rules?

Check if your object has IsBusy = true or authz rules.

This is the actual code in BusinessBase:

    public virtual bool IsSavable
    {
      get 
      {
        bool auth;
        if (IsDeleted)
          auth = Csla.Rules.BusinessRules.HasPermission(Rules.AuthorizationActions.DeleteObject, this);
        else if (IsNew)
          auth = Csla.Rules.BusinessRules.HasPermission(Rules.AuthorizationActions.CreateObject, this);
        else
          auth = Csla.Rules.BusinessRules.HasPermission(Rules.AuthorizationActions.EditObject, this);
        return (auth && IsDirty && IsValid && !IsBusy); 
      }
    }

Dane replied on Sunday, December 18, 2011

Thanks again Jonny.  It was an authorization rule.

Copyright (c) Marimer LLC