Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having trouble grouping a data retrieved from database which has duplication due to a column with data i don't need. i was trying to use distinct or group by to get rid of the redundancies.

var students= db.student.Distinct().Where(c => c.classdate== tomorrow || c.classdate== todayd).ToList();


it will return student's name but also duplicates student record according to course available on that day. I just wanted to get list of students who has class today and tomorrow.

What I have tried:

I have tired
C#
students.GroupBy(x => new { x.Fn  ame, x.classdate});
Posted
Updated 15-Apr-18 23:38pm

1 solution

Try this:
C#
var students= db.student
    .Where(c => c.classdate== tomorrow || c.classdate== todayd)
    .Select(c.studentname)
    .Distinct()
    .ToList();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900