We have a UserRepository repository that reads data from the database using the EntityFramework and the EntityFramework service class that accesses the repository. And our UI is already accessing this service.
Let's say domain model
class User { string Name {get; set; }} How to give data? Really in the form of domain models?
Options come to mind:
Make another class
UserModel (UserDto?), In which I will have only the required fields, and in the repository method (or in the service) convert the domain model (by simply copying the field values). As an option not to copy data,UserModelmay be a descendant ofUser(what difficulties will it cause?)Give the domain model, but first detach it from the context.
dtoand back I use AutoMapper - Baldautomapper. I use entity-framewwork and with the help of navigation properties I do the following: for example,Requesthas aTypenavigation property, so I created a property indto:TypeNameautomapperwill write the value of theNameproperty into it. - Bald