I have a dataset with following table
id domain email
1 google.com av@et.org
2 apple.com gopal@jt.com
3 abc.com av@et.org
4 global.com av@et.org
5 local.com gopaljite@gmail.com
6 xyz.com gopaljite@gmail.com
7 gpl.com gopal@jt.com
8 mno.com av@et.org
9 pqr.co.in gopaljite@gmail.com
10 aad.com av@et.org
Now I need output as following
Sr. Email Domain_Count
1 av@et.org 5
2 gopal@jt.com 2
3 gopaljite@gmail.com 3
How can I do this with LINQ ?
Thanks in advance.
var result=table.GroupBy(c => c.email)
.Select(group => new {
Email = group.Key,
Domain_Count = group.Count()
}).OrderByDescending(x=> x.Domain_Count);
bind to GridView:
yourgidView.DataSource = result.ToList();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.