I am designing an application using C# and Windows Presentation Foundation (WPF). I would like to follow (at least) the very basic rules of software architecture, like dependicies only going in one direction. Also I would like the UI layer to be without any sort of business logic (i.e. the application should work even without the user interface).
I have tried to draw my current thoughts, but I am already struggling with the data layer, as I would prefer not to build a data access layer on top of Entity Framework (the likelyhood of changing data access method in the applications life span is really small).
As I said, I am aware of violating the direction rule, with the connection from Service to DbContext. I just haven't figured out how to go about it (maybe let the BLL consume the DAL?).
But here are the general ideas:
- The DisplayModel is similar to a ViewModel, but must be completely dumb (sort of a DTO). And it will not have its own view. It could be used for instance, as list items. It might implement
INotifyPropertyChanged
. - The ViewModel will get entities from the Service and convert them to DisplayModels using AutoMapper.
- The Model is a shared interface, ensuring that the naming of properties are identical in the DisplayModel and Entity (makes it simpler to use AutoMapper).
Is this a good way to do things or am I walking into a trap with this homemade design?
I have read quite a bit about MVVM and layered architecture. This reading has been the foundation of my design. However, I have not been able to find an actual complete design patter for MVVM and WPF.