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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:58:55+00:00 2026-06-06T12:58:55+00:00

I am trying to group some data without much luck. I have a list

  • 0

I am trying to group some data without much luck.

I have a list of data

 public class TransactionsViewModel
{
    public string BusinessName { get; set; }
    public string Description { get; set; }
    public int TransactionTypeId { get; set; }
    public string TransactionType { get; set; }

    [Display(Name = "Transaction Amount")]
    public decimal TransactionAmount { get; set; }

    [Display(Name = "Transaction Date")]
    public DateTime TransactionDateTime { get; set; }

}

I am wanting to do some grouping on this so I created a couple of classes like

  public class BusinessTransaction
{
    public string Name { get; set; }
    public List<Transaction> Transactions { get; set; }
}

public class Transaction
{
    public decimal TransactionAmount { get; set; }
    public string Description { get; set; }
    public DateTime TransactionDate { get; set; }
    public string TransactionType { get; set; }

}

So I can group by BusinessName that is simple

  var data = from c in transactions
                   group c by c.BusinessName
                   into business
                   select new BusinessTransaction()
                              {
                                  Name = business.Key,



                              };

How can I group transactions now by TransactionDateTime.Date? I am wanting to send back to the client a data structure like

BusinessName
  28-06-12
     Transaction
     Transaction
   27-06-12
     Transaction
 BusinessName
   28-06-12
      Transaction
  • 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-06T12:58:57+00:00Added an answer on June 6, 2026 at 12:58 pm

    I think you want something like:

     var data = from c in transactions
                group c by c.BusinessName
                into business
                select new BusinessTransaction
                {
                    Name = business.Key,
                    Transactions = business.OrderBy(t => t.TransactionDateTime)
                                           .ToList()
                };
    

    EDIT: That’s all the structure you can support with your current BusinessTransaction class. If you wanted to support the grouping directly, you’d have to add another level of nesting in there.

    However, using the existing structure the client can always group things themselves:

    foreach (var business in query)
    {
        Console.WriteLine(business.Name);
        foreach (var group in business.Transactions
                                      .GroupBy(t => t.TransactionDateTime.Date))
        {
            Console.WriteLine("  {0}", group.Key);
            foreach (var transaction in group)
            {
                Console.WriteLine("    {0}", transaction.Description);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to group some sets in disjoint sets. For example, if I have
I have an issue with a query I'm trying to run on some data,
Trying to get data in the most efficient way possible for some reports, using
I have been trying to generate a heatmap in R for some microarray data
Trying to scrape a Y! Group and I can get data from one page
*I am trying to group set of data according some condition using FORTRAN code.
I am trying to transfer some data between tables. The 'NEW' table can have
I'm trying to group a set of data based on the range of an
I am trying to group a data collection and send it to the View
I'm trying to group the following string into three groups. 0:0:Awesome:awesome That being "

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.