Where to make the connection to the database?

Asked

Viewed 164 times

3

In the MVVM pattern where I must connect to the database, in View, Model or Viewmodel?

1 answer

1


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

  • Layer Model

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

  • Layer View

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

  • Viewmodel layer

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

inserir a descrição da imagem aqui

Soon the database related things should stay in the Model layer.

Source.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.