How to dynamically change the implementation in saving the objects for local and remote data portal?

How to dynamically change the implementation in saving the objects for local and remote data portal?

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


brembot posted on Sunday, September 03, 2006

It's mentioned in Rocky's book (Chapter 9) that when saving the objects in local data portal then you must clone the objects so that you can have the original copy if the saving fails. But when saving the objects in remote data  portal, there's no need for cloning because the object is automatically copied from the client to the application server and effectively doing the cloning for you.

How am i going to do that in my UI? I don't have to comment and uncomment my code during the deployement especially if i have so many business objects. Is there a way that my UI can recognize that it's using remote? Or i have to do it manually?

Thanks,
Marlon

Brian Criswell replied on Sunday, September 03, 2006

You could check for the remoting configuration setting and do it manually.  There was some talk a couple of months ago about making the .Save() method do this for us.

brembot replied on Sunday, September 03, 2006

Hello Brian,

Have a look at this sample code. I manually checking it. Is this what you meant?

    If Csla.ApplicationContext.DataPortalProxy.Equals("Local") Then
        ' local data portal -- for development stage
        Dim temp As Roles = _roles.Clone()
        _roles = temp.Save()
    Else
       ' remote data portal -- for deployment stage using .net remoting
        _roles = _roles.Save()
    End If


Thanks,
Marlon



Brian Criswell replied on Sunday, September 03, 2006

Yep.

Copyright (c) Marimer LLC