title: Repository where the aggreate root has a composite primary key
body: <p>Repositories are supposed to work as boundaries for aggregate roots, i.e. <code>IRepository&lt;TAggreagte&gt;</code> would offer CRUD functionality that transactionally saves data to the DB. So far so good.</p>
  
  <p>But what if the <strong>aggregate has a composite primary key</strong>? 
  In my problem it's an Identity <strong>INT</strong> column plus a <strong>SMALLINT</strong> sequence number. (This is the DB design, not my idea!)</p>
  
  <p>The repository examples I have seen either have e.g. <code>void Add(TAggregate aggregate)</code> or <code>bool Add(TAggregate aggregate)</code>.</p>
  
  <p>Example where "eventual consistency" is used:</p>
  
  <p>I want to add an <strong>aggregate A</strong> and I need to call <strong>repository A</strong> and then insert a <em>dependent</em> <strong>aggregate B</strong> using <strong>repository B</strong>, I must know the ID of <strong>aggregate A</strong> after it was inserted.</p>
  
  <p>That is where I am lost. If you insert A, how would you get its ID, especially if it's a composite key?
  The only solution I see is to return the entire object again, so:</p>
  
  <pre><code>TAggregate Add(TAggregate a);
  </code></pre>
  
  <p>Any advice?</p>