Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes the following code violate Persistence Ignorance rule
    primarykey
    data
    text
    <p>a) <em>Domain entities</em> shouldn't contain code related to persistence, thus they should be <em>Persistence Ignorant</em> <strong>PI</strong>. But assuming <em>Domain Model</em> <strong>DM</strong> is designed using <em>Entity Framework</em> and assuming that <em>service layer</em> performs CRUD operation for <strong>POCO</strong> <em>domain entities</em> via <em>Linq-to-Entities</em>, would we argue that <em>service layer</em> accesses DAL directly or via <em>Domain Model</em>:</p> <pre><code>class CustomerService { public string doSomething( ... ) { ... var customer = context.Customers.Where( ... ); ... } ... } </code></pre> <p>b) Does using <em>Linq-to-Entities</em> within <strong>DM</strong> violate <strong>PI</strong> rule? For example, does the following <code>Customer</code> entity violate PI:</p> <pre><code>class Customer { public string InterestedWhatOtherCustomerOrdered( ... ) { ... var orders = context.Orders.Where( ... ); // does this violate PI rule? ... } ... } </code></pre> <p><strong>REPLY TO Luke McGregor:</strong></p> <p>a)</p> <blockquote> <p>Yeah it does as it refers to the context directly. A better way would be to use the internal navigation properties on Customer to perform the same action,</p> </blockquote> <p>So instead <em>navigation properties</em> should contact the <em>context</em>?! But since <em>navigation properties</em> also reside within domain model, couldn't we then argue that by contacting the <em>context</em> directly, they too would violate <strong>PI</strong>? </p> <p>b) According to <em>Fowler's PEAA chapter on Data Mapper</em>, it is ok to extract from <em>Data Mapper</em> any methods needed by the domain code into an interface class, which domain code can then use. How exactly could that be done when using <strong>EF</strong> instead of hand written <em>Data Mapper</em>, in such a manner that we wouldn't violate <strong>PI</strong>?</p> <p>thank you</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. 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