Note that there are some explanatory texts on larger screens.

plurals
  1. PONested LINQ Query Question
    primarykey
    data
    text
    <p>I ran into an issue today and I have been stumped for some time in trying to get the results I am searching for.</p> <p>I currently have a class that resembles the following:</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;} } </code></pre> <p>I have a <code>List&lt;InstanceInformation&gt;</code> and I am trying to use LINQ (or whatever other means to generate paths (<strong>for a file-directory</strong>) based on this list that resemble the following:</p> <pre><code>PatientID/StudyID/SeriesID/InstanceID </code></pre> <p>My issue is the data is currently unstructured as it comes in the previously mentioned form (List) and I need a way to group all of the data with the following constraints:</p> <ul> <li><strong>Group InstanceIDs by SeriesID</strong></li> <li><strong>Group SeriesIDs by StudyID</strong></li> <li><strong>Group StudyIDs by PatientID</strong></li> </ul> <p>I currently have something that resembles this:</p> <pre><code>var groups = from instance in instances group instance by instance.PatientID into patientGroups from studyGroups in (from instance in patientGroups group instance by instance.StudyID) from seriesGroup in (from instance in studyGroups group instance by instance.SeriesID) from instanceGroup in (from instance in seriesGroup group instance by instance.InstanceID) group instanceGroup by patientGroups.Key; </code></pre> <p>which just groups all of my InstanceIDs by PatientID, and it's quite hard to cull through all of the data after this massive grouping to see if the areas in between (StudyID/SeriesID) are being lost. Any other methods of solving this issue would be more than welcome.</p> <p>This is primarily just for <strong>grouping the objects</strong> - as I would need to then iterate through them (using a foreach)</p>
    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.
 

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