Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a look at using partial classes and found that exposing the database model up towards the UI layer would be restrictive. </p> <p>For a few reasons:</p> <ol> <li>The entity model created includes a deep relational object model which, depending on your schema, would get exposed to the UI layer (say the presenter of MVP or the ViewModel in MVVM). </li> <li>The Business logic layer typically exposes operations that you can code against. If you see a save method on the BLL and look at the parameters needed to do the save and see a model that require the construction of other entities (cause of the relational nature the entity model) just to do the save, it is not keeping the operation simple. </li> <li>If you have a bunch of web services then the extra data will need to be sent across for no apparent gain.</li> <li>You can create more immutable DTO's for your operations parameters rather than encountering side effects cause the same instance was modified in some other part of the application.</li> <li><p>If you do TDD and follow YAGNI then you will tend to have a structure specifically designed for the operation you are writing, which would be easier to construct tests against (not requiring to create other objects not realated to the test just because they are on the model). In this case you might have...</p> <pre><code>public class Order { ... public Guid CustomerID { get; set; } ... } </code></pre></li> </ol> <p>Instead of using the Entity model generated by the EF which have references exposed...</p> <pre><code>public class Order { ... public Customer Customer { get; set; } ... } </code></pre> <p>This way the id of the customer is only needed for an operation that takes an order. Why would you need to construct a <code>Customer</code> (and potentially other objects as well) for an operation that is concerned with taking orders?</p> <p>If you are worried about the duplication and mapping, then have a look at <a href="https://github.com/AutoMapper/AutoMapper" rel="nofollow noreferrer">Automapper</a></p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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