Reputation: 7758
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 any possible conversion between the DTO and the Vview model properties.
Upvotes: 4
Views: 1434
Reputation: 178630
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.
Upvotes: 3
Reputation: 81
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/
Upvotes: 1