Click here to Skip to main content
13,668,264 members
Rate this:
 
Please Sign up or sign in to vote.
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
students.GroupBy(x => new { x.Fn  ame, x.classdate});
Posted 15-Apr-18 22:47pm
Updated 15-Apr-18 23:38pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180820.1 | Last Updated 16 Apr 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100