LINQ query help

  • Thread starter Thread starter .nLL
  • Start date Start date
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
 
.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
 
Back
Top