Reputation: 539
I have a table in my database that looks like this:
ID value channel
_________________________
1 50 201
2 55 201
3 60 201
4 10 202
5 12 202
And I want to get a count for the number of distinct channel values. So, in this case that count would be 2.
I am using visual C# with the Entity Framework.
Sorry if this is a simple question, but I couldn't find anything after googling.
Thanks for any help.
Upvotes: 1
Views: 3059
Reputation: 727047
You can use Distinct()
followed by Count()
, like this:
int count = data.Select(d => d.channel).Distinct().Count();
Upvotes: 6