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 9126475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:03:10+00:00 2026-06-17T07:03:10+00:00

I have a List<Fields> collection where the class Fields has the following properties (Name,

  • 0

I have a List<Fields> collection where the class Fields has the following properties

(Name, Currency, Amount, Date, OtherList) where OtherList is a List

Sample values

Name  Currency  Amount Date         F1    F2    F3  
ABC   XX        12     12 Jan 2013  X     Y     Z  
BCA   YY        11     12 Jan 2013  A     B     C  
ABC   XX        10     13 Jan 2013  X     Y     Z 

Now OtherList object will have the values (X, Y, Z) for record1 and (A, B, C) for record2 et.el

What I need to do is apply an aggregation on the above list on the fields Name, Currency, F1, F2 and F3 so that the result is as follows.

Output

Name  Currency  Amount Date         F1    F2    F3  
ABC   XX        22     13 Jan 2013  X     Y     Z  
BCA   YY        11     12 Jan 2013  A     B     C  

Any idea how I can do this?

Thanks.

  • 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-06-17T07:03:11+00:00Added an answer on June 17, 2026 at 7:03 am

    You can use LINQ:

    var aggrList = list
        .GroupBy(x => new { x.Name, x.Currency, x.F1, x.F2, x.F3 })
        .Select(grp => new {
                Name = grp.First().Name,
                Currency = grp.First().Currency,
                Amount = grp.Sum(x=>x.Amount),
                Date = grp.Max(x=>x.Date),
                F1 = grp.First().F1,    
                F2 = grp.First().F2,    
                F3 = grp.First().F3,    
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list, that has three fields: Title, PublishingRollupImage and Description. I want
I have filled List<Object1> Object 1 contain 2 fields (int id & string name)
I Have following in my struts.xml file <action name=ProductVerification class=com.frontend.ProductVerification> <result name=success>/jsp/product_verification.jsp</result> <result name=input>/jsp/product_verification.jsp</result>
I have a class with primitive fields like the following: public class Person{ String
Say I have the following Hibernate-mapped class: public class ClassA { @OneToMany(fetch=EAGER) private List<ClassB>
I have a Person class with two properties: name and address . I want
I have a class Data which implements Serializable interface. This class has such fields
I have a list of fields/columns that comprises of Sharepoint specific fields/columns, my own
I have a list of entities which contain some of it fields as other
I am trying to build JSON from two fields. Say, I have a list

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.