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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:13:11+00:00 2026-06-05T03:13:11+00:00

I have these scenario: //This class maps to the Item table in the database

  • 0

I have these scenario:

//This class maps to the "Item" table in the database
public class Item
{
   public int itemID { get; set;}
   public string itemName { get; set; }
   public int quantity { get; set; }
}

//Items record are returned from the database as list    
List<Item> items = ItemDAO.GetItems();

I want to generate a report that include aggregate values (from query/Stored Procedure)

ItemID| ItemName | Qty | QtySoldThisMonth | QtySoldThisYr
-----------------------------------------------------------
123   | Vit. C   |  20 |   55             |    400
239   | Maloxin  |  25 |   12             |    210

The Item class does not have these extra fields
This would have been easier with datatable which could have varying number of columns but I am using a list

Please, how would I go about this

  • 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-05T03:13:12+00:00Added an answer on June 5, 2026 at 3:13 am

    you can always create another DTO specifically for that aggregated view and use that in your reports.

    A little more general solution than a specific DTO for each view would be to create a DTO for reports on Item and use a collection of fields instead of class properties to store aggregate values in the DTO.

    For instance:

     class AggregatedReportField {
         public string FieldName { get; set; }
         public decimal FieldValue { get; set; }
     }
    
     class ItemReportDTO {
    
         public Dictionary<string, AggregatedReportField> ReportFields { get; private set; }
    
         public ItemReportDTO()
         {
             ReportFields = new Dictionary<string, AggregatedReportField>();
         }
    
         public void Add(AggregatedReportField field)
         {
             if (!ReportFields.ContainsKey(fieldl.FieldName))
                  ReportFields.Add(field.FieldName, field);
         }
     }
    

    in your DAO, you would then first get the values from the database, create AggregatedReportField instances for each value and add them with a name to your DTO. In your report, you would then have to refer to your aggregated values with DTO.ReportFields[“SomeValue”].FieldValue.

    the code above is just an example and contains a few bad practices (exposed Dictionary<>).

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

Sidebar

Related Questions

I have the following class: public class DocketType : Enumeration<DocketType, int, string> { public
This is my scenario. I have a generic class: public class Tuple<T> extends ArrayList<T>
I have the following scenario: public class Login { public virtual int Id {
I have these two classes public class Person { } public class Company {
HI all, my scenario public class Permission { public virtual Function Function { get;
I am a NHibernate newbie. Suppose you have a Customer class like this public
Consider the scenario I have values assigned like these Amazon -1 Walmart -2 Target
I have a simple producer/consumer scenario, where there is only ever a single item
I have these structs: typedef struct _Frag{ struct _Frag *next; char *seq; int x1;
I have these two modules : package G1; sub new { my $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.