user1031034
user1031034

Reputation: 856

Return unique records using LINQ

Sorry, for title... I haven't any idea how call it.

In my database I have records with dates:

2012-02-03
2012-02-03
2012-02-05
2012-02-05
2012-02-05
2012-02-06

And how make a linq query to display just records with the single dates, I mean:

2012-02-03
2012-02-05
2012-02-06

Upvotes: 3

Views: 418

Answers (1)

voidengine
voidengine

Reputation: 2579

Use Distinct(), e.g.

IEnumerable<string> distinctDates = dates.Distinct()

For more complicated cases, you may also use GroupBy(), but Distinct is enough for this

Upvotes: 5

Related Questions