Hi
In below linq query i want to get only distinct records
public List GetStudentsByMentor(Int32 MentorId)
{
List Result = (from t in context.View_SessionDeliveryCalendarDetails_Students
where (MentorId != 0 ? t.MentorID == MentorId : 1 == 1)
select t).ToList();
return Result;
}
Thanks
Jignesh KumarPosted Apr 6, 2023, 5:44 AM
Hello Ramco,
Have you created below as extension method and build your solution,
And try below one after that,
Ramco RamcoPosted Apr 6, 2023, 4:23 AM
Hi Jignesh
It is givine error DistinctBy does not exist in current context. I want distinct by Student id. I want to display studentid,name,mobileno
Thanks
Jignesh KumarPosted Apr 6, 2023, 4:08 AM
Hello Ramco,
If you want to do distinct by multiple column then you can create extention method as below,
You can use as below in your code,
Ramco RamcoPosted Apr 6, 2023, 4:04 AM
Hi
It is giving error - Cannot implicitly convert system.collections.gereric.list to system.collections.gereric.list
Thanks
Amit MohantyPosted Apr 6, 2023, 3:57 AM
Ramco RamcoPosted Apr 6, 2023, 3:49 AM
Hi Amit
Sorry i want distinct to be by StudentId
Thanks
Amit MohantyPosted Apr 6, 2023, 3:43 AM
Try this