Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following the DDD let's separate your entities from the logic that operates on them. Personally, I have used Repository pattern to create one generic repository as well as some specialized repositories that operate on my entities. The reposotory can operate on constructor-given ObjectContext or will create a new one (from configuration) when none is specified.</p> <p>My example IRepository interface:</p> <pre><code>public interface IRepository&lt;T&gt; where T : class { /// &lt;summary&gt; /// Return all instances of type T. /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; IQueryable&lt;T&gt; All(); /// &lt;summary&gt; /// Return all instances of type T that match the expression exp. /// &lt;/summary&gt; /// &lt;param name="exp"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; IEnumerable&lt;T&gt; Find(Func&lt;T, bool&gt; exp); /// &lt;summary&gt;Returns the single entity matching the expression. /// Throws an exception if there is not exactly one such entity.&lt;/summary&gt; /// &lt;param name="exp"&gt;&lt;/param&gt;&lt;returns&gt;&lt;/returns&gt; T Single(Func&lt;T, bool&gt; exp); /// &lt;summary&gt;Returns the first element satisfying the condition.&lt;/summary&gt; /// &lt;param name="exp"&gt;&lt;/param&gt;&lt;returns&gt;&lt;/returns&gt; T First(Func&lt;T, bool&gt; exp); /// &lt;summary&gt; /// Mark an entity to be deleted when the context is saved. /// &lt;/summary&gt; /// &lt;param name="entity"&gt;&lt;/param&gt; void Delete(T entity); /// &lt;summary&gt; /// Create a new instance of type T. /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; T CreateInstance(); /// &lt;summary&gt;Persist the data context.&lt;/summary&gt; void SaveAll(); } </code></pre>
    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