Note that there are some explanatory texts on larger screens.

plurals
  1. POconcrete sense of IRepository<T> vs Repository if I do not do unit tests with mocks
    text
    copied!<p>I have this:</p> <pre><code>public interface IRepository&lt;T&gt; where T : class { void Delete(T entity); void Add(T entity); void Attach(T entity); void Detach(T entity); void SaveChanges(); } </code></pre> <p>now for every of my Entity I make concrete classes implementing the generic IRepository =></p> <pre><code>public class SchoolclassRepository : IRepository&lt;Schoolclass&gt; { public void Delete(Schoolclass entity) { throw new NotImplementedException(); } public void Add(Schoolclass entity) { throw new NotImplementedException(); } public void Attach(Schoolclass entity) { throw new NotImplementedException(); } public void Detach(Schoolclass entity) { throw new NotImplementedException(); } public void SaveChanges() { throw new NotImplementedException(); } } </code></pre> <p>In my ViewModel`s constructor (mvvm pattern) I do this =></p> <pre><code>IRepository&lt;Schoolclass&gt; repo = new SchoolclassRepository(); </code></pre> <p>What advantage is there with IRepository when I have anyway to write the code for my CRUD operations in every entities class?</p> <p>In Customer, Product, Pupil whatever class I implement the <code>IRepository&lt;Product&gt;</code> , <code>IRepository&lt;Customer&gt;</code>, <code>IRepository&lt;Pupil&gt;</code> etc... and I implement the methods of the interface.</p> <p>Why could I not say =></p> <pre><code>SchoolclassRepository repo = new SchoolclassRepository(); ??? </code></pre> <p>I do not care for having the possibility to write unit tests for a small app.</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