Where to connect to the database?

3

In the MVVM standard where should I connect to the database, in the View, Model, or ViewModel?

    
asked by anonymous 20.05.2015 / 18:07

1 answer

1

When you use the MVVM standard, an application is divided into the following layers:

  • Model Layer

The model layer includes all code that implements the application's central logic and defines the types needed to model the application domain. This layer is completely independent of the view and view model layers.

  • View Layer

The view layer defines the user interface using declarative markup. Data binding marking defines the connection between the specific components of the user interface and various view model (and sometimes model) members.

  • ViewModel Layer

The view model layer provides data binding targets for the view layer. In many cases, the view model exposes the model layer directly or provides members that encapsulate specific members of the model layer. The view model layer can also define members to control data that is relevant to the user interface, but not to the model layer, such as the order of displaying a list of items

SoonthingsrelatedtothedatabaseshouldstayintheModellayer.

Source.

    
20.05.2015 / 18:12