Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The answer to your question entirely depends on your objective here. </p> <p>If you are creating domain level Interfaces with the rationale that you might (at some stage later) swap over the DAL from Entity Framework to something entirely different (such as a 3rd party web-service, or perhaps xml serialisation) - then you will be aiming to completely seperate any <strong>concrete</strong> logic between the Domain and the DAL.</p> <p>Where possible, you want your Domain to operate on the Domain entites/interfaces and your DAL to operate on DAL entities/interfaces, whilst implementing the interfaces specified in your Data Access </p> <p>Therefore, your DAL object DAL.Person should contain a Book object, and implement from the IPerson interface at a domain level.</p> <p>I'll give some examples as requested:</p> <pre><code>#region Domain Objects public interface IPerson { List&lt;IBook&gt; Books { get; private set; } } public interface IBook { string Name { get; private set; } } #endregion #region DAL/Entity Framework Auto Generated classes public class Person : IPerson { public List&lt;Book&gt; Books {get; private set;} } public class Book : IBook { public string Name { get; private set; } } #endregion </code></pre> <p>Contrary to Jodrells comment, I think that if there was a requirement to 'Hot-Swap' the Data Access Layer there could be a case for the DataAccess layer implementing the interface contracts described in the Domain layer.</p> <p>To be honest though, it is rare that I have seen this requirement - and usually you are best off extending the auto-generated Entity Framework classes (through <code>partial</code>) and passing around the application, removing the duplication that would be required by specifying the domain objects and contracts themselves. So in essence, your Entity-Framework classes <strong>becomes</strong> your Domain layer.</p> <p>And I should mention that you should use POCO classes as per comments above</p>
 

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