views:

530

answers:

1

Hi there,

I have successfully created a asp mvc app which basically has interface, service and dataacces - AKA the repository pattern..

What would be the best way to call my service (my repository pattern) from an MVVM structured WPF app..

From what i see.. in the MODEL in wpf i presume i call my service (repository pattern) from the model and then return data to my viewmodel for displaying on the view??

Should this model be thin i.e. has little code and just call the service.. and return data to the viewmodel for processing or should the MODEL call the repository service and do the processing in the model before retruning to the viewmodel??

I am a little confused how i can use my WORKING repository pattern in the realm of a new WPF MMVM app i am designing...

Any ideas?

Thanks

+3  A: 

I think you are complicating matters by focusing on the fact that your data access uses a repository pattern. It's irrelevant. You could be using Joe's Box' O' Data pattern and your underlying question would be the same. Let's forget you are using that pattern and focus on what you are doing: getting data from a data source.

When you get data from a data source, this is generally considered to be your Model. It's data, but it lacks certain behavioral things that make it appropriate for showing on the screen (lack of INotifyPropertyChanged implementation, for example). What people generally do with this is adapt their business objects into something that can be more readily used by a view (a view model).

You will use this technique regardless of the pattern in use for getting your data.

Anderson Imes
Thanks for your comment, yep you are right i was complicating matters :-) ... I presume i can still use the service (in respect to the Repository patter) .. the service is where all my business logic is .. so hence i will carry on using this .. and use the viewmodel to addapt whats returned from my service(buss logic) for display in my view???
mark smith
That is correct. You'll need to take that data and enrich it in your viewmodel with display-specific things like "IsSelected" or any of that kind of property.
Anderson Imes