Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think this will yield what you're looking for:</p> <pre><code>public class InstanceInformation { public string PatientID { get; set; } public string StudyID { get; set; } public string SeriesID { get; set; } public string InstanceID { get; set; } public override string ToString() { return String.Format("Series = {0} Study = {1} Patient = {2}", SeriesID, StudyID, PatientID); } } class Program { static void Main(string[] args) { List&lt;InstanceInformation&gt; infos = new List&lt;InstanceInformation&gt;() { new InstanceInformation(){ SeriesID = "A", StudyID = "A1", PatientID = "P1" }, new InstanceInformation(){ SeriesID = "A", StudyID = "A1", PatientID = "P1" }, new InstanceInformation(){ SeriesID = "A", StudyID = "A1", PatientID = "P2" }, new InstanceInformation(){ SeriesID = "A", StudyID = "A2", PatientID = "P1" }, new InstanceInformation(){ SeriesID = "B", StudyID = "B1", PatientID = "P1"}, new InstanceInformation(){ SeriesID = "B", StudyID = "B1", PatientID = "P1"}, }; IEnumerable&lt;IGrouping&lt;string, InstanceInformation&gt;&gt; bySeries = infos.GroupBy(g =&gt; g.SeriesID); IEnumerable&lt;IGrouping&lt;string, InstanceInformation&gt;&gt; byStudy = bySeries.SelectMany(g =&gt; g.GroupBy(g_inner =&gt; g_inner.StudyID)); IEnumerable&lt;IGrouping&lt;string, InstanceInformation&gt;&gt; byPatient = byStudy.SelectMany(g =&gt; g.GroupBy(g_inner =&gt; g_inner.PatientID)); foreach (IGrouping&lt;string, InstanceInformation&gt; group in byPatient) { Console.WriteLine(group.Key); foreach(InstanceInformation II in group) Console.WriteLine(" " + II.ToString()); } } </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