Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Calrification on Linq

Calrification on Linq

Scheduled Pinned Locked Moved LINQ
databasehelpcsharplinqtutorial
2 Posts 1 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joe Rozario
    wrote on last edited by
    #1

    Dear friends i have small clarification on linq to SQL, i am new to linq i have query like these

    select p.PatientStudyDataId,p.DicomPatientName,p.DicomPatientId,p.DicomStudyDate,count(i.ImageDataId)
    From dbo.PatientStudyData as p
    join dbo.Modality as m on m.ModalityId = p.ModalityId
    left join dbo.PatientSeriesData as s on s.PatientDataId =p.PatientStudyDataId
    left join dbo.PatientImageData as i on i.PatientSeriesId =s.PatientSeriesId
    group by p.PatientStudyDataId,p.DicomPatientName,p.DicomPatientId,p.DicomStudyDate

    i was trying to convert to linq

    var query = from patient in DataContext.Select()
    join modality in DataContext.Select() on patient.ModalityId equals modality.ModalityId
    join series in DataContext.Select() on patient.PatientStudyDataId equals series.PatientDataId
    into JoinedSerieas
    from series in JoinedSerieas.DefaultIfEmpty()
    join image in DataContext.Select() on series.PatientSeriesId equals image.PatientSeriesId
    into JoinedImages
    from image in JoinedImages.DefaultIfEmpty()
    group patient by new {image.ImageDataId,patient.PatientStudyDataId, patient.DicomPatientName, patient.DicomPatientId, patient.DicomStudyDate, modality.Modality1} into list

                            select new PatientStudyTransferObject
                            {
                                PatientStudyDataId = list.Key.PatientStudyDataId,
                                DicomPatientName = list.Key.DicomPatientName,
                                DicomPatientId = list.Key.DicomPatientId,                                
                                Modality = list.Key.Modality1,
                                DicomStudyDate = list.Key.DicomStudyDate,
                                Count = list.Count()
                            };
    

    My Problem is inside the count in sql "count(i.ImageDataId)" like these how to do this linq? if you want to give your own linq query , you are most welcome please help me By Joe

    J 1 Reply Last reply
    0
    • J Joe Rozario

      Dear friends i have small clarification on linq to SQL, i am new to linq i have query like these

      select p.PatientStudyDataId,p.DicomPatientName,p.DicomPatientId,p.DicomStudyDate,count(i.ImageDataId)
      From dbo.PatientStudyData as p
      join dbo.Modality as m on m.ModalityId = p.ModalityId
      left join dbo.PatientSeriesData as s on s.PatientDataId =p.PatientStudyDataId
      left join dbo.PatientImageData as i on i.PatientSeriesId =s.PatientSeriesId
      group by p.PatientStudyDataId,p.DicomPatientName,p.DicomPatientId,p.DicomStudyDate

      i was trying to convert to linq

      var query = from patient in DataContext.Select()
      join modality in DataContext.Select() on patient.ModalityId equals modality.ModalityId
      join series in DataContext.Select() on patient.PatientStudyDataId equals series.PatientDataId
      into JoinedSerieas
      from series in JoinedSerieas.DefaultIfEmpty()
      join image in DataContext.Select() on series.PatientSeriesId equals image.PatientSeriesId
      into JoinedImages
      from image in JoinedImages.DefaultIfEmpty()
      group patient by new {image.ImageDataId,patient.PatientStudyDataId, patient.DicomPatientName, patient.DicomPatientId, patient.DicomStudyDate, modality.Modality1} into list

                              select new PatientStudyTransferObject
                              {
                                  PatientStudyDataId = list.Key.PatientStudyDataId,
                                  DicomPatientName = list.Key.DicomPatientName,
                                  DicomPatientId = list.Key.DicomPatientId,                                
                                  Modality = list.Key.Modality1,
                                  DicomStudyDate = list.Key.DicomStudyDate,
                                  Count = list.Count()
                              };
      

      My Problem is inside the count in sql "count(i.ImageDataId)" like these how to do this linq? if you want to give your own linq query , you are most welcome please help me By Joe

      J Offline
      J Offline
      Joe Rozario
      wrote on last edited by
      #2

      i found the answer .... i have changed these two lines in my linq query

      group new {patient, image} by new {patient.PatientStudyDataId, patient.DicomPatientName, patient.DicomPatientId, patient.DicomStudyDate, modality.Modality1 } into list

      and

      Count = list.Count(p =>p.image.ImageDataId ==p.image.ImageDataId)

      i am getting answer... anyway thanks for reading my question and answer... by joe

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups