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
|
I have read many item in the forum and the blog and still don't think that I understand how best to solve my problem with LightSpeed and yet it seems to me it should be a common scenario. I have a WCF service that is running on a remote server somewhere. I have a WPF application that is running on my client machine. In the database I have an Application table with Id, Name & StatusId columns and an ApplicationStatus table with StatusId & Status columns. Reading various other posts and referring to the help file, the recommended approach is essentially to keep the entity classes on the server side and move their dto objects between server and client. On the client when I create a new application, I create the application dto object with Name and StatusId, pass across to the server, xxx.CopyTo the entity class and Add to the UnitOfWork and Save. On saving I get an error saying that Status should be set. How should I achieve this whilst passing round dto's that don't have the relationships and therefore only know of the id column? As a secondary point, I know that this has been discussed elsewhere, but is there an up to date view on the recommended approach for being able to validate data on the client side before passing to the server given that the dto has no awareness of the validation rules? |
|
|
On my main point, I apologise this was me being daft and not ready the exception message properly. I would however appreciate a response regarding validation and the current think/best practice from your perspective |
|
|
Hi David, In a distributed system this becomes a bit tricky but generally the recommended way of going about this would be to use a declarative approach to supplying metadata about the validations to be performed on a per property basis (check out http://laribee.com/the-smart-dto for some more thoughts on the merits of this approach) and then you can use an appropriate validation technique at the client to check the required validations for the DTO prior to sending it back over the wire (and being checked on the server).
Jeremy
|
|
|
Thanks for this. I probably had assumed some kind of declarative approach and the link was useful. I guess my follow up would be the this is exactly what the Entity class is using in LightSpeed (i.e. applying validation attributes to the fields of the entity). It would make sense for the client and therefore the DTO to make use of these same attributes and for the attributes to be added to the DTO at the same time. Is there anyway that the validation attributes could be applied to the DTOs and then for the client to make use of the validation routines in the LightSpeed assemblies? |
|
|
Hi David, Unfortunately not as it currently stands as the validation code is fairly embedded into the core framework and is only really applicable to entities so you would need to use a seperate validation library to cater for client side validation at this stage. It is something we have previously looked in to, but have not yet put enough priority around implementing - would be interested to hear if anyone else has tackled this problem or has some interest in us decoupling the validation framework and making it a bit more pluggable given the glut of 3rd party validation frameworks out there.
Jeremy |
|