This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I am planning to use the <entity>Dto classes (or, atm, actually only 1) for my remoting, only to find out that the Id field was not present in the Dto class. Doing a search on this forum gave me this thread: http://www.mindscape.co.nz/forums/Thread.aspx?PostID=4658 I can understand the reasoning behind this decission, however my project requires an array of entities to be send. These entities wont be used for database actions themselves but will generate database actions in other tables which need to be linked to the entities that where sent, as such I need the Id's. Now the post is rather old (which is why I didnt bump it) and mentions things (might be) improve in 3.0 and it also mentions hooks which could be used to add the Id field to the (generated) Dto class. If there is no automated way to get the Id added to the Dto class, what is the 'Correct (tm)' way (code sample?) to add the Id to the Dto class without breaking functionality ? I did notice BeforeCopy<entity> partial static functions, but no sample code on how to use these (or if these are "the way to go"). (small fun fact, I didnt know you could have partial functions) We only need the Id added to one table, and we mix and match different type of Id's (int / long's) so adding it to DtoBase (which didnt seem to be used anyway) would not be the prefered way to go. Regards, Jerremy (this time I did search the help file but couldnt find much about it, the update-example added Id as a seperate parameter, which in our case wouldnt work due to passing an array list of Dto's) |
|
|
No, this didn't change in 3.0, so the partial class / partial method solution is still the right way to go. To add the Id property to the DTO class: partial class WidgetDto { To populate the DTO Id property: partial class MyModelDtoExtensions { Incidentally the technique in the help file can still be adapted to the array scenario, you just create a DTO-with-ID class and send an array of those: // Data contract, but ignoring WCF attributes etc. // Service method |
|