Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Entity Framework's <code>DbContext</code> basically resembles a <em>Repository</em> (and a <em>Unit of Work</em> as well). You don't necessarily have to abstract it away in simple scenarios.</p> <p>The main advantage of the repository is that your domain can be ignorant and independent of the persistence mechanism. In a layer based architecture, the dependencies point from the UI layer down through the domain (or usually called business logic layer) to the data access layer. This means the UI depends on the BLL, which itself depends on the DAL.</p> <p>In a more modern architecture (as propagated by domain-driven design and other object-oriented approaches) the domain should have no outward-pointing dependencies. This means the UI, the persistence mechanism and everything else should depend on the domain, and not the other way around.</p> <p>A repository will then be represented through its interface inside the domain but have its concrete implementation outside the domain, in the persistence module. This way the domain depends only on the abstract interface, not the concrete implementation.</p> <p>That basically is object-orientation versus procedural programming on an architectural level.</p> <p>See also the <a href="http://alistair.cockburn.us/Hexagonal+architecture" rel="noreferrer"><strong>Ports and Adapters</strong> a.k.a. <strong>Hexagonal Architecture</strong></a>.</p> <p>Another advantage of the repository is that you can create similar access mechanisms to various data sources. Not only to databases but to cloud-based stores, external APIs, third-party applications, etc.</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