Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Alright, let's take a look:</p> <ul> <li>EmployeeDataAccess.cs and EmployeeRepository.cs <em>probably</em> (but not necessarily, look below) could be combined into one class, say 'EmployeeRepository' that fetches the data and returns your model classes.</li> <li>Your 'EmployeeModel' is in fact a view model, so we can remove 'EmployeeViewModel' class and rename the 'EmployeeModel' to 'EmployeeViewModel'.</li> <li>Now this point depends on what your own preference, but you can go for general repository instead of repository-per-class; in such case, you'd have one <code>Repository</code> class with generic CRUD methods for all data models.</li> </ul> <p>Then you end up with:</p> <ul> <li>Every data-model class gets its own view model and view (that's 3 classes per entity)</li> <li>There's one repository, either called in the view model and then results are mapped, or you can introduce another thin layer which will be used in view model that will call the repository and do the mapping (model &lt;==> view model) for you in one go.</li> </ul> <p>Not so bad, is it? :)</p> <p>Don't overthink it and don't overengineer your solution. Having three hundred different indirection layers in a simple application is pointless IMO. You can develop them as you go if the application grows and there's a justified need for separate layer.</p> <p>[EDIT] I assumed, of course, that the 'model' class is an entity class at the same time; that comes with any kind of ORM, even the lightweight ones (Dapper springs to mind).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload