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

  • SEARCH
  • Home
  • 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 3793038
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:42:52+00:00 2026-05-19T12:42:52+00:00

I have a list of objects of this class: public class DataPoint { public

  • 0

I have a list of objects of this class:

public class DataPoint
{
    public class Item
    {
        public string name { get; set; }
        public int total { get; set; }
    }
    public List<Item> Items { get; set; }
    public DateTime Date { get; set; }
}

I want to convert that list of DataPoints into a list of objects of this class:

public class ChartSeries
{
    public string Name { get; set; }
    public List<uint> Values { get; set; }
}

Here is an explicit example of the list of DataPoints

IEnumerable<DataPoint> data = new List<DataPoint>() { 
    new DataPoint() { date = DateTime.Today.AddDays(-4), Items = new List<DataPoint.Item>() {new DataPoint.Item() {name="Pirates", total=90 } , {new DataPoint.Item() {name="Buccaneers", total=20 } }}}, 
    new DataPoint() { date = DateTime.Today.AddDays(-3), Items = new List<DataPoint.Item>() {new DataPoint.Item() {name="Pirates", total=80 } , {new DataPoint.Item() {name="Buccaneers", total=19 } }}},
    new DataPoint() { date = DateTime.Today.AddDays(-2), Items = new List<DataPoint.Item>() {new DataPoint.Item() {name="Pirates", total=70 } , {new DataPoint.Item() {name="Buccaneers", total=18 } }}},
    new DataPoint() { date = DateTime.Today.AddDays(-1), Items = new List<DataPoint.Item>() {new DataPoint.Item() {name="Pirates", total=60 } , {new DataPoint.Item() {name="Buccaneers", total=17 } }}},
    new DataPoint() { date = DateTime.Today.AddDays(-0), Items = new List<DataPoint.Item>() {new DataPoint.Item() {name="Pirates", total=50 } , {new DataPoint.Item() {name="Buccaneers", total=16 } }}}
};

I want to convert that first list into a list of ChartSeries that would look like this:

IEnumerable<ChartSeries> series = new List<ChartSeries>() {
        new ChartSeries() { Name = "Pirates", Values = new List<uint>() { 90, 80, 70, 60, 50} },
        new ChartSeries() { Name = "Buccaneers", Values = new List<uint>() { 20, 19, 18, 17, 16} },
};

How can I do this with Linq?

  • 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-19T12:42:52+00:00Added an answer on May 19, 2026 at 12:42 pm

    Tested in LINQPad:

    var q = from d in data
            from i in d.Items
            group i by i.name into g
            select new ChartSeries{
                Name = g.Key,
                Values = g.Select(i => (uint)i.total).ToList()
            };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a List of objects with this implementation: class Locations { public string
I have a class: public class MyObject { public string Name; public int Age;
I have a simple class like this: public class myClass { public List<string> innerList;
I have a simple object like this public class Test { public string Name
I have a list of objects (Debtors) in this structure public class DebtorDto {
I have a List of String objects that are pipe delimited. something like this:
Lets say that I have a list of objects like so: public class FlatModel
i have a java class like this public class A { private String field1;
I have list of objects type Node ( items ). And Node class has
I have a specialized class, BusinessObjectList, with this declaration: public class BusinessObjectList<T> : List<BusinessObject>

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.