Quick question

Posts   
 
    
Chad
User
Posts: 5
Joined: 12-Oct-2004
# Posted on: 07-Apr-2005 14:31:38   

Hi all,

I’m by no means an expert so a quick question to make myself feel at ease. Would the following in my client tier calling a remote service be ok? or do I need to return a “Contact Entity” from the method if I want to reuse the _currentContact reference? It might be a silly question but I don't trust things that are so easy stuck_out_tongue_winking_eye

Thanks simple_smile

<client>


XXX.Remoting...GetUniqueInstance().ContactServices.UpdateContactEntity(_currentContact);

<server>


  public class ContactServices : MarshalByRefObject ,IContactServices
  {
    public void UpdateContactEntity(ContactEntity contact)
    {
      DataAccessAdapter daa = new DataAccessAdapter XXX.Security.Server.Config.SQLStoreConnectionString);
      daa.SaveEntity(contact,true);
      daa.CloseConnection();
    }
...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Apr-2005 19:15:15   

Remoting will re-create instances using data passed between client and server. This means that keeping a reference to an object and comparing it later on with a received entity is not going to work, as the received entity will always be different, as it is re-created.

Normally, you return the service as MarshallByRef and pass the entities by value.

Frans Bouma | Lead developer LLBLGen Pro
Chad
User
Posts: 5
Joined: 12-Oct-2004
# Posted on: 08-Apr-2005 03:56:36   

Otis wrote:

Remoting will re-create instances using data passed between client and server. This means that keeping a reference to an object and comparing it later on with a received entity is not going to work, as the received entity will always be different, as it is re-created.

Normally, you return the service as MarshallByRef and pass the entities by value.

Believe it or now I know about the above and that we're actually getting a new instance of the object. So by judging from the answer there isn't really anything wrong with the way I'm doing it. The question whould then be..

Why do

_currentContact = XXX...UpdateContactEntity(_currentContact);

if we can just do

XXX...UpdateContactEntity(_currentContact);

?

Sorry for making this a not-so-quick question.

ps. And thanks for a great product. It's such a relive not having to write any more queries for 10 table dataset business objects. smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Apr-2005 12:27:40   

Chad wrote:

Otis wrote:

Remoting will re-create instances using data passed between client and server. This means that keeping a reference to an object and comparing it later on with a received entity is not going to work, as the received entity will always be different, as it is re-created.

Normally, you return the service as MarshallByRef and pass the entities by value.

Believe it or now I know about the above and that we're actually getting a new instance of the object. So by judging from the answer there isn't really anything wrong with the way I'm doing it. The question whould then be..

Why do

_currentContact = XXX...UpdateContactEntity(_currentContact);

if we can just do

XXX...UpdateContactEntity(_currentContact);

?

Sorry for making this a not-so-quick question.

I think the second option would be ok, saves you a return of the entity data. the service should act stateless, i.e. it works with the stuff it gets passed in.

ps. And thanks for a great product. It's such a relive not having to write any more queries for 10 table dataset business objects. smile

smile

Frans Bouma | Lead developer LLBLGen Pro