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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:27:09+00:00 2026-05-31T02:27:09+00:00

Lets say that I have a list of objects like so: public class FlatModel

  • 0

Lets say that I have a list of objects like so:

public class FlatModel
{
    public string groupName { get; set; }
    public decimal value1 { get; set; }
    public decimal value2 { get; set; }
    public decimal value3 { get; set; }
}

and I want to map them to the following object, by grouping based on GroupName

public class GroupedModel
{
    public string groupName { get; set; }
    public List<ModelValues> values { get; set; }
}

public class ModelValues
{
    public decimal value1 { get; set; }
    public decimal value2 { get; set; }
    public decimal value3 { get; set; }
}

Is there a straight-forward way to do this using Automapper, Value Injector, or some other object mapping utility?

  • 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-31T02:27:11+00:00Added an answer on May 31, 2026 at 2:27 am

    Can it work for you?

            var arr = new List<FlatModel>();
    
            var result = from p in arr
                         group p by p.groupName into g
                         select 
                             new GroupedModel { 
                                 groupName = g.Key, 
                                 values = (from q in g 
                                                    select 
                                                        new ModelValues { 
                                                            value1 = q.value1, 
                                                            value2 = q.value2, 
                                                            value3 = q.value3 }).ToList() 
                             };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have query that gets following List Item Objects with Set of
Lets say I have an object class Person { public string Name { get;
Lets say that I have the following code: public class Shelter<A extends Animal, B
lets's say I have: // all objects have valid mapping to database public class
I have code that looks like this: public class Polynomial { List<Term> term =
Lets say you have various objects of arbitrary type that you would like to
Let's say I have an object MyObject that looks like this: public class MyObject
Let's say I have an object: Person { public string FirstName {get;set;} public string
Let's say that I have classes like this: public class Parent { public int
Lets say I retrieve an entity object that looks like this: @Entity public class

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.