I have a database like this which i would like to get the top 10 country ranking with ties with linq to entities. We can use index to solve the ranking problem if tie ranking is omitted. However, what i needed here is to query tie ranking (with tie) of the top 10 country that has most count.
ID CountryID
1 1
2 1
3 1
4 2
5 3
........
db.TableA.GroupBy(p => p.CountryID).
Select(group =>
new
{
Rank = ????????????
Count = group.Count(),
Items = group.Select(i => new
{
CountryName = i.Country.CountryName
}).Distinct()
}).OrderByDescending(group => group.Count)
Rank CountryName
1 USA
2 UK
2 UK
4 Singapore
5 China
6 France
6 Ukraine
8 Country x
9 Country y
10 Country z