Question about cloning in the DataPortal

Question about cloning in the DataPortal

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


Brian Criswell posted on Monday, September 18, 2006

I have been thinking about the whole concept of cloning an object before save when using the local DataPortal.  I was wondering if anyone thought the following change would work if I changed the try block in DataPortal.Update to the following:

try
{
    if (!proxy.IsServerRemote && SomeConfigurationSetting)
    {
       result = proxy.Update(((ICloneable)obj).Clone(), dpContext);
    }
    else
        result = proxy.Update(obj, dpContext);
}

RockfordLhotka replied on Monday, September 18, 2006

I don't see anything wrong with this. Assuming it works reliably, it seems like a good future addition (though it would be a breaking change, which is ugly - unless I used a config switch to turn it on).

Brian Criswell replied on Monday, September 18, 2006

RockfordLhotka:
I don't see anything wrong with this. Assuming it works reliably, it seems like a good future addition (though it would be a breaking change, which is ugly - unless I used a config switch to turn it on).

I figured it would be a problem as a runtime breaking change, hence the SomeConfigurationSetting property/thingy/whatever.Wink [;)]  I will see about adding it in to a project at work and check the results.  I guess the only difference for someone who knew they were using a local DataPortal would be that they would have to make sure to use obj = obj.Save().  So there would be a reason to use obj = obj.Save() regardless of whether running a local or remote DataPortal.

Thanks for the feedback.  I will post here later when I have had a chance to try it out.

Copyright (c) Marimer LLC