Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3617578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:38:33+00:00 2026-05-18T22:38:33+00:00

i am trying to consolidate an ienumerable list that i am serializing i have

  • 0

i am trying to consolidate an ienumerable list that i am serializing

i have data that looks like this:

Internet explorer    10
Internet explorer    15 
Mozille firefox      10

I was it to look like:

Internet explorer    25
Mozille firefox      10

my class looks like:

 public class BrowserVisits
 {
  public string BrowserName { get; set; }

  public int Visits { get; set; }
        }

my current query to serialize an ienumerable list (r) looks like:

var browserVisits = from r in reportData
      select new BrowserVisits
      {
       BrowserName = r.Dimensions.First(d => d.Key == Dimension.Browser).Value,
       Visits = int.Parse(r.Metrics.First(d => d.Key == Metric.Visits).Value)
      };

how do i go a group by with sum in linq?

do i need to go two queries, or can i do a single one.

apologies if this sounds vague, its been a long day, but am more than happy to add to this if it needs clarification

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:38:34+00:00Added an answer on May 18, 2026 at 10:38 pm

    What about:

    public static IEnumerable<BrowserVisits> SumGroups(
        IEnumerable<BrowserVisits> visits)
    {
        return visits.GroupBy(
            i => i.BrowserName,
            (name, browsers) => new BrowserVisits() {
                BrowserName = name,
                Visits = browsers.Sum(i => i.Visits)
            });
    }
    

    This works for me against your sample data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out how I can do this properly. The print_r looks like
I have two databases, on two separate SQL Servers (trying to consolidate both). This
This is the configuration I have, and I'm trying to consolidate this into a
So I have a problem... I am trying to consolidate 5 or so bilingual
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I have the following code I am trying to consolidate. (here are two examples)
I'm trying to experiment with array_splice and I get an output like this (from
I currently have something like this: UPDATE table1 SET column1 = REPLACE(column1, 'abc', 'abc1')
I'm trying to consolidate some code that is very messy but I want to
Okay, I have been trying to find a solution for this and I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.