jeudi 8 juin 2023

Implementation of ServiceLayer & DataAccessLayer in MVVM design pattern

I have just started a customer relation system and wanted to use MVVM design pattern in C#. But after some research, I get confuse with the view model and model. I am not sure where should I locate my code to access data from database. I believe that I have to add method (eg. GetCustomerById()) in view model and that method return a customer model back to view model but I am not sure about it.

Also, after searching on the internet all the MVVM pattern shows simple View-ViewModel-Models as the image below.

Original MVVM pattern

I was wondering, is it possible or correct for me to add a service layer or data access layer in between the view models and model like the screenshot shows?

MVVM pattern with Service Layer & Data Access Layer

Aucun commentaire:

Enregistrer un commentaire