0

I have comming multiple records in strongly typed list. I want distinct record with all columns based on AssessmentID column so for example I am getting two records with AssessmentID = 2455 so I want pick 2455 once in list

List<AssessmentWithRemidiationViewModel> activeAssessmentWithRemidiation = AssessmentRemidiationRelay.GetActiveAssessmentWithRemediation(null);
var query_b = (from b in activeAssessmentWithRemidiation
               where ((b.AssessorID == ContextSession.StaffID) 
                        || (b.ModuleLead == ContextSession.StaffID) 
                        || (b.SeniorStaffID == ContextSession.StaffID)) 
                        && b.ClinicalSupervisorCheck == true
                    select b).ToList();

well as no one can answer this so they mark as duplicate, any way I found asnwer and is as following;

My Answer

  var query_b = (from b in activeAssessmentWithRemidiation
                      where ((b.AssessorID == ContextSession.StaffID) || (b.ModuleLead == ContextSession.StaffID) || (b.SeniorStaffID == ContextSession.StaffID)) && b.ClinicalSupervisorCheck == true
                      select b).ToList();


       var filteredList = query_b.GroupBy(x => x.AssessmentID)
                          .Select(i=>i.First()).ToList();
K.Z
  • 5,201
  • 25
  • 104
  • 240

0 Answers0