c# - Data Access Design Pattern -


I am currently preparing a Windows 8 Store app for which I need to call many web service calls. The call returns a JSON string which I am deserilizing in objects. I'm using the MIVVM design pattern with Caliberan. WinRT for Micro Viral

Initially, to get data from each of my visual models for web service calls, I created a class, datastore, which declared itself as a stable example of the properties of that class Which were related to all my models. When a web service call is required, I called a steady class method in "APIIDA", which read in a dictionary of parameters, serialized those parameters in JSON, created an API call and returned the JSON result to the DataStore class Gave. At which point JSON was deserialized and used to update datastore properties.

This happened in the form of duplicated code and a very messed datastore class.

My question is, what would be a good design pattern to use, where should the model be used to return JSN from website calls?

It appears that your initial effort has broken '' and inspired the dirty datastore class has been done.

My implementation of the View-Modell data operation is to keep a collection of 'View ModellPipulator' classes. Every service in the viewport holds a reference to a view-modelpipulator, which is responsible for the view-models properties Hydrates.

In order to promote code reuse, it is possible that a single view model has different populations (for example, ' CarCollectionViewModel ' or ' Honda Collection ViewModelPopulator 'or' KiaCollectionViewModelPopulator ') Therefore the reference is actually a IViewModelPopulator & lt; T & gt; is where T is visible.

This results in loose coupling between view-models and data access layer. In your example, I keep Jason Vilan (probably through some supportive methods) in the View Modelpipular classes.

In addition to this, it allows you to inject the expressions in the UI layer in a view-model (at the example given below), or at the runtime to code them in Codebahind.

  & lt; Page. Datacontex & gt; & Lt; VM: SearchPageViewModel & gt; & Lt; VM: SearchPageViewModel.ViewModelPopulator & gt; & Lt; VMP: SearchPageViewModelPopulator / & gt; & Lt; / VM: SearchPageViewModel.ViewModelPopulator & gt; & Lt; / VM: SearchPageViewModel & gt; & Lt; /Page.DataContext>    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -