Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An <code>IRepository</code> is an interface you specify when you want to implement the Repository Pattern. As @Brian Ball stated, it's not part of .NET it is an interface that you create. </p> <p>Developers using the Repository Pattern widely recommend the use of an interface for the implementation. For example, in the application I am developing right now, I have 5 repositories. 4 specific and 1 generic. Each one inherits from an <code>IRepository</code> which ensures I will not have issues down the road with differences in implementations.</p> <p>As far as code examples, I'll try:</p> <pre><code>interface IRepository&lt;T&gt; where T : class { IQueryable&lt;T&gt; Select(); } </code></pre> <p>Implemented as a generic repository:</p> <pre><code>public class Repository&lt;T&gt; : IRepository&lt;T&gt; where T : class { public IQueryable&lt;T&gt; Select() { return this.ObjectContext.CreateObjectSet&lt;T&gt;(); } } </code></pre> <p>Implemented as a specialized repository:</p> <pre><code>public class EmployeeRepository : IRepository&lt;Employee&gt; { public IQueryable&lt;Employee&gt; Select() { return this.ObjectContext.Employees; } } </code></pre> <p>Both the <code>Repository&lt;T&gt;</code> and <code>EmployeeRepository</code> implement <code>IRepository</code>, however they go about performing the querying slightly differently. The generic repository has to create an object set of T before it can try to do anything.</p> <p>Keep in mind that <code>Repository&lt;T&gt;</code> is supposed to be locked to the interface, where as <code>EmployeeRepository</code> can implement more specialized methods to accomplish more complex logic.</p> <p>I hope this helps you a little.</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.
    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