2

I’m developing a WCF Service implementing basic CRUD operations.

When implementing the UPDATE method should the method receive an instance of the object or only the updates?

For the purpose of the question let’s say I have PERSON type with various properties; (My object is more complex, has more properties of various different types)

  Name (string) 
  Surname (string)
  Age (int)

And a few more complex properties:

Father (of type PERSON)   
Children (of type LIST<Person>).  

I then:

1) Invoke the GETPERSON method. (Bob)
2) Update Bob's age and the name of his Father.
3) Invoke the update method.

  • Should I send Bob PERSON object?

  • Or only the UPDATEs I made to Bob, for instance maybe using collection of a new type (with name of the property and it's new value for instance)?

Thanks

  • Looks like you are writing *kind of* your own ORM, why don't use the existing ones ? – Habib Mar 04 '15 at 13:49
  • @Habib No, it's a service. – Sergio Garcia Mar 04 '15 at 13:53
  • Something like [Using WCF with ADO.Net Entity Model to Expose CRUD Operation as a SOAP Enabled Service](http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/using-wcf-with-ado-net-entity-model-to-expose-crud-operation-as-a-soap-enabled-service/) – Habib Mar 04 '15 at 13:54
  • 1
    The example uses the WCFDTO object which it is a very simple object. But what should I do if instead of a simple type like this one it’s a very big and complex object and I only change a property, should I send the whole object back to the server? – Sergio Garcia Mar 04 '15 at 14:35
  • My point is to use the Existing ORM, for example if you use Entity framework, You will be able to load a complete object, or modify only existing properties. In that case you don't have to write your own classes for table mapping and also CRUD operations would be available through EF. See [this thread](http://stackoverflow.com/q/3642371/961113) on how to update only specific fields or a complete object from db. – Habib Mar 04 '15 at 14:41

1 Answers1

1

My advice is that you should let the persistence layer handle this logic (what are the updated properties) and let the client does the pertinent modifications. The client should only know the retrieved object, modify the properties and then send the object to the persistence logic

Daniel Uribe
  • 778
  • 4
  • 17