DirectoryRecord<T> Method

Summary
Represents a typed query against a DICOMDIR file.
Syntax
C#
C++
public static Queryable<T> DirectoryRecord<T>( 
   this DicomDataSet dataset 
) 
vb[VB Syntax] 
<ExtensionAttribute()> 
Public Shared Function DirectoryRecord(Of T)( _ 
   ByVal _dataset_ As DicomDataSet _ 
) As Queryable(Of T) 
[ExtensionAttribute()] 
public: 
static Queryable<T^>^ DirectoryRecordgeneric<typename T> 
(  
   DicomDataSet^ dataset 
)  

Parameters

dataset
The dataset that holds information on a DICOM basic directory.

Type Parameters

T
The entity type of the query.

Return Value

A object that provides LINQ based access to a DICOM basic directory.

Remarks

This extension method represents a query that returns a collection of zero or more objects of a specific type. A valid DICOMDIR must be present in the dataset parameter before a query can be executed. A DICOMDIR query will be executed in the following scenarios:

  • When it is acted upon, such as during a foreach(C#) or For Each (VB) enumeration.
  • When it is assigned to fill a List<T> collection.

The following operations are provided by the DICOMDIR LINQ Provider.

  • SelectMany
  • String Methods (Contains, StartWith, and EndsWith)
  • LINQ Projection
  • Subqueries
Example

This example will show how to perform several different types of LINQ based queries on a DICOM basic directory.

C#
using Leadtools.Dicom; 
using Leadtools.Dicom.Common; 
using Leadtools.Dicom.Common.Extensions; 
using Leadtools; 
using Leadtools.Dicom.Common.Linq.BasicDirectory; 
using Leadtools.Dicom.Common.DataTypes; 
 
 
 
[DicomKey(DicomDirKeyType.Patient)] 
public class PatientEntity 
{ 
   [Element(DicomTag.PatientID)] 
   public string Id 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.PatientName)] 
   public string Name 
   { 
      get; 
      set; 
   } 
} 
 
[DicomKey(DicomDirKeyType.Study)] 
public class StudyEntity 
{ 
   [Element(DicomTag.PatientID)] 
   [DicomKey(DicomDirKeyType.Patient)] 
   public string PatientId 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.StudyDate)] 
   public DateTime? Date 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.StudyTime)] 
   public DateTime? Time 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.StudyDescription)] 
   public string Description 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.StudyInstanceUID)] 
   public string InstanceUID 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.StudyID)] 
   public string Id 
   { 
      get; 
      set; 
   } 
 
   [Element(DicomTag.AccessionNumber)] 
   public string AccessionNumber 
   { 
      get; 
      set; 
   } 
} 
 
public void TestDicomLinq() 
{ 
   DicomEngine.Startup(); 
 
   using (DicomDataSet ds = new DicomDataSet()) 
   { 
      ds.Load(_DicomDirFile, DicomDataSetLoadFlags.None); 
      FindPatients(ds); 
      FindStudies(ds); 
      FindPatientStudy(ds); 
   } 
 
   DicomEngine.Shutdown(); 
} 
 
private void FindPatients(DicomDataSet ds) 
{ 
   var patients = from patient in ds.DirectoryRecord<PatientEntity>() 
                  select new { Name = patient.Name, Id = patient.Id }; 
 
   foreach (var patient in patients) 
   { 
      Console.WriteLine("Id: " + patient.Id); 
      Console.WriteLine("Name: " + patient.Name); 
   } 
} 
 
private void FindStudies(DicomDataSet ds) 
{ 
   var studies = from study in ds.DirectoryRecord<StudyEntity>() 
                 select study; 
 
   foreach (var study in studies) 
   { 
      Console.WriteLine("Patient Id: " + study.PatientId); 
      Console.WriteLine("Accession #: " + study.AccessionNumber); 
      Console.WriteLine("Study Id: " + study.Id); 
   } 
} 
 
private void FindPatientStudy(DicomDataSet ds) 
{ 
   var query = from patient in ds.DirectoryRecord<PatientEntity>() 
               select new 
               { 
                  patient, 
                  Studies = from study in ds.DirectoryRecord<StudyEntity>() 
                            where study.PatientId == patient.Id 
                            select study 
               }; 
 
   foreach (var item in query) 
   { 
      Console.WriteLine("Patient: " + item.patient.Id); 
      foreach (StudyEntity study in item.Studies) 
      { 
         Console.WriteLine("    Instance UID: " + study.InstanceUID); 
      } 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2022.4.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Common Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.