Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't know exacly what you need, but this (very long code) will return a dictionary (of dictionaries...) grouped as you said (i.e. <code>PatientID/StudyID/SeriesID/InstanceID</code>):</p> <pre><code>var byPatient = new Dictionary&lt;string, Dictionary&lt;string, Dictionary&lt;string, Dictionary&lt;string, InstanceInformation&gt;&gt;&gt;&gt;(); foreach (var patientGroup in instances.GroupBy(x =&gt; x.PatientID)) { var byStudy = new Dictionary&lt;string, Dictionary&lt;string, Dictionary&lt;string, InstanceInformation&gt;&gt;&gt;(); byPatient.Add(patientGroup.Key, byStudy); foreach (var studyGroup in patientGroup.GroupBy(x =&gt; x.StudyID)) { var bySeries = new Dictionary&lt;string, Dictionary&lt;string, InstanceInformation&gt;&gt;(); byStudy.Add(studyGroup.Key, bySeries); foreach (var seriesIdGroup in studyGroup.GroupBy(x =&gt; x.SeriesID)) { var byInstance = new Dictionary&lt;string, InstanceInformation&gt;(); bySeries.Add(seriesIdGroup.Key, byInstance); foreach (var inst in seriesIdGroup) { byInstance.Add(inst.InstanceID, inst); } } } } </code></pre> <p><strong>P.S.</strong><br> I've considered <code>InstanceID</code> as unique among all instances. </p> <p>Otherwise, the last dictionary level should be: <code>Dictionary&lt;string, List&lt;InstanceInformation&gt;&gt;</code></p> <p><strong>EDIT:</strong></p> <p>Reading your last comment, I think you don't need a real <code>GroupBy</code>, but rather an <code>OrderBy().ThenBy()...</code></p> <pre><code>foreach (var el in instances.OrderBy(x =&gt; x.PatientID) .ThenBy(x =&gt; x.StudyID) .ThenBy(x =&gt; x.SeriesID) .ThenBy(x =&gt; x.InstanceID)) { // it yields: // Pat1 Std1 Srs1 Inst1 // Pat1 Std1 Srs1 Inst2 // Pat1 Std1 Srs2 Inst1 // Pat1 Std2 Srs2 Inst2 // ... } </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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