Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually there is a general consensus now that Domain repositories should not be generic. Your repository should express what you can do when persisting or retrieving your entities.</p> <p>Some repositories are readonly, some are insert only (no update, no delete), some have only specific lookups...</p> <p>Using a GetAll return IQueryable, your query logic will leak into your code, possibly to the application layer.</p> <p>But it's still interesting to use the kind of interface you provide to encapsulate Linq <code>Table&lt;T&gt;</code> objects so that you can replace it with an in memory implementation for test purpose.</p> <p>So I suggest, to call it <code>ITable&lt;T&gt;</code>, give it the same interface that the linq <code>Table&lt;T&gt;</code> object, and use it <strong>inside</strong> your specific domain repositories (not instead of).</p> <p>You can then use you specific repositories in memory by using a in memory <code>ITable&lt;T&gt;</code> implementation.</p> <p>The simplest way to implement <code>ITable&lt;T&gt;</code> in memory is to use a <code>List&lt;T&gt;</code> and get a <code>IQueryable&lt;T&gt;</code> interface using the .AsQueryable() extension method.</p> <pre><code>public class InMemoryTable&lt;T&gt; : ITable&lt;T&gt; { private List&lt;T&gt; list; private IQueryable&lt;T&gt; queryable; public InMemoryTable&lt;T&gt;(List&lt;T&gt; list) { this.list = list; this.queryable = list.AsQueryable(); } public void Add(T entity) { list.Add(entity); } public void Remove(T entity) { list.Remove(entity); } public IEnumerator&lt;T&gt; GetEnumerator() { return list.GetEnumerator(); } public Type ElementType { get { return queryable.ElementType; } } public IQueryProvider Provider { get { return queryable.Provider; } } ... } </code></pre> <p>You can work in isolation of the database for testing, but with true specific repositories that give more domain insight.</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.
    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