Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, the exact context is not quite clear to me, but I believe your code should look like this:</p> <pre><code>public interface IParameter&lt;T&gt; { bool Match(T entry); } public abstract class DataRepository&lt;T, TParameter&gt; where TParameter : IParameter&lt;T&gt; { public abstract IEnumerable&lt;T&gt; RetrieveAll(TParameter parameter1); public abstract bool Delete(TParameter parameter1); } // public interface IAudit {/* ... */} public interface IAuditSearch : IParameter&lt;IAudit&gt; {/* ... */} public class SearchRepository : DataRepository&lt;IAudit, IAuditSearch&gt; { public override bool Delete(IAuditSearch parameter1) { // iterate by collection items using parameter matching // CODE GOES HERE (DELETE ALL FOUND ENTRIES) } public override IEnumerable&lt;IAudit&gt; RetrieveAll(IAuditSearch parameter1) { // iterate by collection items using parameter matching // CODE GOES HERE (RETURN ALL FOUND ENTRIES) } } </code></pre> <p>Different IAuditSearch implementation will incapsulate a "search by different parameter" logic:</p> <pre><code>var guidSearchResult = repository.RetrieveAll( new GuidSearch(new Guid("00000000-0000-0000-0000-000000000000"))); var idRangeSearchResult = repository.RetrieveAll( new IDRangeSearch(1000, 2000)); </code></pre> <p>where GuidSearch and IDRangeSearch are implemented as:</p> <pre><code>public class GuidSearch : IAuditSearch { Guid ID; public GuidSearch(Guid id) { this.ID = id; } public bool Match(IAudit entry) { /* search implementation using ID(Guid)*/ throw new NotImplementedException(); } } public class IDRangeSearch : IAuditSearch { int StartID; int EndID; public IDRangeSearch(int startId, int endId) { this.StartID = startId; this.EndID = endId; } public bool Match(IAudit entry) { /* search implementation using ID range (StartID...EndID)*/ throw new NotImplementedException(); } } </code></pre>
    singulars
    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. 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