LINQ query help

N

.nLL

Hi, i've got below query
--------------------------
TopCountriesRepeater.DataSource = ds.Tables[1].AsEnumerable()
.GroupBy(row => row.Field<string>("CountryCode"))
.Select(group => new { CountryCode = group.Key, CountryName
= group.Key, UsersFromIp = group.Sum(row =>
row.Field<int>("UsersFromIp")) })
.OrderByDescending(g => g.UsersFromIp);
-----------------------

What i want to do is instead of

CountryName = group.Key

I want to select "CountryName" column of the row when executing query.
Can someone give me heads up for this?

Thanks
 
M

miher

.nLL said:
Hi, i've got below query
--------------------------
TopCountriesRepeater.DataSource = ds.Tables[1].AsEnumerable()
.GroupBy(row => row.Field<string>("CountryCode"))
.Select(group => new { CountryCode = group.Key, CountryName
= group.Key, UsersFromIp = group.Sum(row =>
row.Field<int>("UsersFromIp")) })
.OrderByDescending(g => g.UsersFromIp);
-----------------------

What i want to do is instead of

CountryName = group.Key

I want to select "CountryName" column of the row when executing query.
Can someone give me heads up for this?

Thanks

Hi,

Try something like :
CountryName = group.First().Field<...>("...")

-Zsolt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top