Note that there are some explanatory texts on larger screens.

plurals
  1. POMapping from Tuple to ICollection
    text
    copied!<p>Ok so I get data from mySql and it comes back as a ReadOnlyCollection<code>&lt;Tuple&lt;DbAudit, DbAuditItem&gt;&gt;</code>. Now I have to map from this to my <code>Audit</code> and <code>AuditItem</code> classes. The <code>Audit</code> part is working like so:</p> <pre><code>return audits.Select((AuditMapper.Map)).ToReadOnlyCollection(); </code></pre> <p>and in the auditmapper this happens.</p> <pre><code>public static Audit Map(Tuple&lt;DbAudit, DbAuditItem&gt; source) { if (source == null) return null; return new Audit( null, (AuditKind) source.Item1.AuditKindId, source.Item1.DateCreated, null, source.Item1.ContainerItemId, source.Item1.UserId, Item2.Select(AuditItemMapper.Map).ToReadOnlyCollection() ); } </code></pre> <p>but the Item2.Select... line isn't working and i'm not sure how else to write it. Any ideas?</p> <p>EDIT: First the Item2 line is supposed to be source.Item2.Select.</p> <p>I've also realized my logic isn't making sense because each Item2 is only one auditItem and i'm trying to add it to a collection. Audit item looks like this:</p> <pre><code>public Audit(string applicationToken, AuditKind auditKind, DateTime dateCreated, string containerName, string containerItemId, int userId, ICollection&lt;AuditItem&gt; auditItems) { m_applicationToken = applicationToken; m_auditKind = auditKind; m_dateCreated = dateCreated; m_containerName = containerName; m_containerItemId = containerItemId; m_userId = userId; m_auditItems = auditItems; } </code></pre> <p>and the auditItem is:</p> <pre><code>public AuditItem(string name, string data, string oldData) { m_name = name; m_data = data; m_oldData = oldData; } </code></pre> <p>But I see that the way I have is isn't going to work. I need somehow to take each distinct Item1 of the tuple and put each corresponding Item2 into a collection that will go into the audit item...</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