Folks,
I’m trying to figure out a pattern or best practice to translate data from the domain objects/data source over to the ‘ViewModel’ object. In my particular example, the domain object is the WCF proxy objects. Any call to the WCF methods will populate these proxy objects which finally gets transferred over to the ‘ViewModel’ objects. See Architectural diagram
This microsoft article: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx talks about using a Repository pattern. It’s mentioned under ‘The Data Model and Repository’ section. Is that the best approach? Can someone advice me?
dorman
Yes, you need to have a repository.
That will give you some advantages, like easy testing of the view model; also an easy switching to another kind of repository later.
In terms of the article you provided, – it gave them an advantage of unit-testing the view-model logic; and, later on, they can switch from XML files repository to the SQL server repository (as an example).
Just make sure to have abstract repository injected into ViewModel.