Does DataPortal_Fetch call MarkOld?

Does DataPortal_Fetch call MarkOld?

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


tiago posted on Monday, November 14, 2011

Hi Rocky,

In Using CSLA4-02 Objects, about the MarkOld method you say that DataPortal takes care of it on Insert and Update. I guess this means DataPortal_Insert/Child_Insert and DataPortal_Update/Child_Update take care of calling MarkOld.

What about DataPortal_Fetch? Does it also takes care of calling this method? BTW I can't see a single example of MarkOld usage either on PTracker or EncapsulatedInvoke/EncapsulatedInvokeDto.

JonnyBee replied on Monday, November 14, 2011

This is the code from f.ex SimpleDataPortal - so yes, MarkOld is called on the object before DataPortal_Fetch:

        // create an instance of the business object.
        obj = new LateBoundObject(objectType);
 
        target = obj.Instance as IDataPortalTarget;
 
        if (target != null)
        {
          target.DataPortal_OnDataPortalInvoke(eventArgs);
          target.MarkOld();
        }
        else
        {
          obj.CallMethodIfImplemented("DataPortal_OnDataPortalInvoke", eventArgs);
          obj.CallMethodIfImplemented("MarkOld");
        }
 
        // tell the business object to fetch its data
        if (criteria is EmptyCriteria)
          obj.CallMethod("DataPortal_Fetch");
        else
          obj.CallMethod("DataPortal_Fetch", criteria);
 
        if (target != null)
          target.DataPortal_OnDataPortalInvokeComplete(eventArgs);
        else
          obj.CallMethodIfImplemented(
            "DataPortal_OnDataPortalInvokeComplete",
            eventArgs);
 
        // return the populated business object as a result
        return new DataPortalResult(obj.Instance);

Copyright (c) Marimer LLC