Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In many-to-one relations (in our case <code>Delivarable</code> and <code>Job</code>), the relation itself is expressed with exactly <strong>one</strong> DB column. The child table (<code>Deliverable</code>) has (must have) a reference column with the Job <em>ID (Code)</em>. </p> <p>So, what we need for our mapping, is the column inside the Delivarable table, containing the relation to the Job. The <code>JobCode</code> column. (Not sure if there is any, from example above)</p> <p>And this must be used on both sides:</p> <p>Delivarable:</p> <pre><code>public DeliverableMap() { ... // References( x =&gt; x.Deliverable) ... I guess it is typo in the question snippet References( x =&gt; x.Job) .Column("JobCode") ; // column of table Deliverable } </code></pre> <p>Job:</p> <pre><code>public JobMap() { ... HasMany(x =&gt; x.Deliverables) .KeyColumn("JobCode"); // column of table Deliverable } </code></pre> <p>Other words, both column names in this mapping, are in fact the names of <strong>one</strong> column. Both are mapped to child (Deliverable) table's column.</p> <p>EXTENDED: based on mapping changes in the question</p> <p>The <code>Deliverable</code> object, has its <code>ID</code> (column CODE) the same as the reference to <code>Job</code> (column CODE). This seems to be weird. </p> <p>That's also explaining the fact, that all the Deliverable items inside the JOB collection are the <strong>same</strong> (identical). Unique Deliverable (defined by its CODE) can be only one. The Job in this scenario cannot have more then one Deliverable (because it's referenced by unique CODE column). It seems like <strong>the one-to-one</strong> scenario.</p> <p>The reason why there are <strong>more</strong> items <strong>same</strong> is harder to judge. It would be good to see the query you are using.</p> <p>But I would really twice check the column mapping. Deliverable, should have reference to Job in a column called "JobCODE"... supporting more Delivrables to be related...</p>
 

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