F
F
FairyFox57002020-02-19 14:41:53
WPF
FairyFox5700, 2020-02-19 14:41:53

How to bind repositories to ViewModel?

In my project, I need to implement data access from a database.
This data will be displayed on the view (eg GetAll()).
Is it possible to bind some kind of repository to the viewModel (for example, through the constructor) and will this not be an access violation (since the data layer must be associated with the model, and not directly with the viewModel)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-02-19
@FairyFox5700

if you are talking about MVVM, then View interacts with ViewModel, and ViewModel with Model. Therefore, if you are trying to work with the Model from the ViewModel in order to simply receive data and send it to the View, then everything is OK. But if you perform any "logical" operations in the viewmodel, then it's wrong

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question