In the MVVM standard where should I connect to the database, in the View, Model, or ViewModel?
In the MVVM standard where should I connect to the database, in the View, Model, or ViewModel?
When you use the MVVM standard, an application is divided into the following layers:
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.
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.
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.