Note that there are some explanatory texts on larger screens.

plurals
  1. POInheritance/design issue with domain entities that can be individual or combined
    primarykey
    data
    text
    <p>I have completely confused myself trying to design the necessary interfaces and abstracts to accomplish loading of domain entities that can be used by themselves as well as combined into an aggregate. Wow. That was a buzzword mouthful. Essentially, I have two objects that I would like to have base-type "load" functionality, but when these two objects are combined into one, I run into multiple inheritance.</p> <p>So, I have my entities, which are like this (I'd draw</p> <pre><code>public class Account public class Document public class AccountDocument { public Account Account{get;set;} public Document Document{get;set;} } </code></pre> <p>Then, I have interfaces, like this:</p> <pre><code>public interface IAccountRepository { Account Load(IDataContext context); } public interface IDocumentRepository { Document Load(IDataContext context); } public interface IAccountDocumentRepository { AccountDocument Load(IDataContext context); } </code></pre> <p>Since both Account and Document can (and are) being derived from for other entities, I want to provide base functionality in the implementation so that I follow DRY.</p> <pre><code>public abstract class AccountRepositoryBase : IAccountRepository { Account Load(IDataContext context) { //implementation for loading the Account from the context } } public abstract class DocumentRepositoryBase : IDocumentRepository { Document Load(IDataContext context) { //implementation for loading the Document from the context } } </code></pre> <p>This works fine for the individual Account and Document objects and their derivations, but the problem I can't seem to wrap my head around is how to handle the AccountDocument...</p> <pre><code>public class AccountDocumentRepository : AccountRepositoryBase, DocumentRepositoryBase { //This is not possible, of course, due to multiple inheritance. } </code></pre> <p>I know the solution can't be that hard, but I am completely tangled up and can't straighten out how I can provide the base "Load" functionality only once. Please help!</p> <p>Thanks in advance.</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.
 

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