I have a WCF based application that uses the services to access repositories on the server side. I am passing DTOs from the server to the client and was wondering how best to make the DTOs part pf the view model.
I have a workign example of just plain properties on the view model but was unsure how to deal with actual DTO objects and a开发者_如何学运维ny possible conversion between the DTO and the Vview model properties.
Your question is very general, but the pattern usually looks something like this:
public class CustomerViewModel : ViewModel
{
private readonly CustomerDTO _customer;
...
public string Name
{
get { return _customer.Name; }
set
{
if (_customer.Name != value)
{
_customer.Name = value;
OnPropertyChanged(() => this.Name);
}
}
}
}
You'll need to ask a more specific question if this doesn't make any sense.
I'm actually developing a library for mapping your dtos to your view models and your view models to your view. You can check it out at http://fluentviewmodel.codeplex.com/
精彩评论