CslaAutoCloneOnUpdate and Remote Data Portal

CslaAutoCloneOnUpdate and Remote Data Portal

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


JohnB posted on Thursday, January 31, 2008

I have a question about the CslaAutoCloneOnUpdate config setting.

According to the 3.0 book:
"...This only matters when you are using a local data portal configuration. If you are using a remote
data portal configuration then the business object is “cloned” across the network and the save occurs on the application server. But with a local data portal configuration the save occurs on the client workstation, and it is the actual object instance that is saved. So the complete best practice is to clone the object only when using a local data portal and not
when using a remote data portal."


Since I am currently using remoting, I understand this to mean I do not need to clone my objects before saving. I should set 'CslaAutoCloneOnUpdate=True' and the framework will handle it? Or does the config setting not even matter to me?

Thanks,
John

KKoteles replied on Thursday, January 31, 2008

JohnB,

The CslaAutoCloneOnUpdate does not even matter to you because it only applies when the DataPortal is run locally (which you've just stated you don't do since you are using remoting).  If you read a little further (or look through some of the posts on this forum), Rocky explains that in the process of remoting the DataPortal serializes your object for you - which in turn essentially performs the cloning functionality that CslaAutoCloneOnUpdate (or in the earlier versions the save examples) would do for you.

Ken

JohnB replied on Thursday, January 31, 2008

KKoteles:

If you read a little further (or look through some of the posts on this forum), Rocky explains that in the process of remoting the DataPortal serializes your object for you - which in turn essentially performs the cloning functionality that CslaAutoCloneOnUpdate (or in the earlier versions the save examples) would do for you.


Ken,

I read that but just wanted to make sure since the documentation does not specifically state, at least to me, that when you are using remoting, you don't need the config setting nor do you need to clone on save.

Thanks,
John

RockfordLhotka replied on Thursday, January 31, 2008

The most correct answer is that if you don't do explicit Clone() calls in your UI code then you should set autoclone to true.

That has no effect with a remote data portal, but makes the local data portal work correctly - and even if you are running with a remote data portal in production you might use a local data portal for some debugging scenarios during development, so this is just a wise step.

If you are doing explicit Clone() calls in your UI code then autoclone should be false. But I recommend removing those explicit calls in favor of using autoclone, because it is more consistent and simplifies your code.

In CSLA .NET 3.5 autoclone is true by default (though you can set it to false if you need the old behavior).

ajj3085 replied on Friday, February 01, 2008

Yes, I'm looking forward to moving to 3.5, where I will also remove my clone code.  Having moved to remoting recently, this is something that would have been helpful.  Fortunately, it will continue to be helpful, because its easier to debug with the local portal than the remote. 

Copyright (c) Marimer LLC