I am working on an ASP.NET MVC application using SQL Dapper for retrieval and NHibernate for CRUD. I am facing some problems with layer separation.
I have repositories say UserRepository which has public User GetUsersList() method. Here “User” is an NHibernate entity. The problem here is I need to display a field in the UI which is not present as a property in User like ‘HasAltContacts’ which I am directly retrieving from an SQL query.
Now, my question is do I need to create separate DTO’s and leave these NHibernate entities and build repositories (at least READ METHODS) around these classes?
Define a view model that will contain all the properties your view requires. Then have your controller action populate this view model by querying the various data sources you have and pass this view model to the view.