I am creating a WPF Smart Client app which uses WCF and NHibernate on the back end. I am making good progress but have a question with regards how to get databack from the WCF Service to enable buttons / functionality in the WPF smart client.
At the moment I have a CreateProduct screen which ultimately calls WCFProductService.CreateProduct(ProductDTO productDetails) to the WCF service. This works fine and creates a product record in the database. The CreateProduct method does not currently return anything.
I do not want to create a massive DTO in memory then send that across the wire. I am aiming to do something more along the lines of Create The Product then AddSomething, AddSomething else as seperate tasks.
To this end I have a button AddAttribute. Add Attribute has to work in the context of a product at the WCF service level so I need to send a ProductId in the AddAttributeDTO. Of course at this stage the ProductDTO does not have an Id in it as it has been created entirely in memory before being sent off to the WCF Service.
I assume that the WCF service call CreateProduct will need to return some sort of object that contains the Id and other data
What form should this take?
Are there any documents on guidance / best practice for this?
How can then I use this to enable the relevant buttons?
Thanks in advance for any assistance
Alex
You can simple return a DTO back to the consumer, adding whatever information you need to.
Your OperationContract would then look like
I would also add the your idea about adding ‘parts’ to an already existing product is probably overkill. Unless you product contains literally 100000’s of attributes, it will not consume anywhere near the sort of memory you should worry about. It will be a lot cleaner and simpler to maintain having a single DTO with corresponding methods for adding, updating, etc.