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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:48:35+00:00 2026-06-13T09:48:35+00:00

I have the following class public class Booking { public string Group { get;

  • 0

I have the following class

public class Booking
{
    public string Group { get; set; }
    public BookingType Type { get; set; }
    public BookingStatus Status { get; set; }
    public InvoiceFreq { get; set; }
    public InvoiceLevel { get; set; }
}

That I’d need to group them by all properties in Linq so that the last two properties form one new field in the grouped result.
Like this:

        Group   Type    Status      InvoiceType          
        -------------------------------------------
        Group1  Online  New         Daily-Single
        Group2  Phone   Accepted    Daily-Single
        Group3  Store   Accepted    Weekly-Single
        Group3  Store   Accepted    Weekly-Bulk

Here the InvoiceFreq will be Daily / Weekly and the InvoiceLevel = Single or Bulk.

The query I have so far is this:

        var query = from b in Bookings
                        group b by new
                        {
                            b.Group, 
                            b.Type, 
                            b.Status,
                            b.InvoicingFrequency,
                            b.InvoicingLevel
                        } into bookingGroup
                        select new BookingSummaryLine()
                        {
                            Group = bookingGroup.Key.UserGroup,
                            Type = bookingGroup.Key.UserGroup,
                            Status = bookingGroup.Key.FinancialStatus,
                            InvType = String.Format({0}-{1},bookingGroup.Key.InvoicingFrequency, bookingGroup.Key.InvoicingLevel
                        }; 

This of course does not give the desired result as the two properties are in the anonymous type separately.

Is there any way to achieve this in 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-06-13T09:48:37+00:00Added an answer on June 13, 2026 at 9:48 am

    This should work:

    var query = from b in Bookings
        group b by new
        {
            b.Group, 
            b.Type, 
            b.Status,
            InvType = String.Format({0}-{1},b.InvoicingFrequency, b.InvoicingLevel)
        } into bookingGroup
        select new BookingSummaryLine()
        {
            Group = bookingGroup.Key.UserGroup,
            Type = bookingGroup.Key.UserGroup,
            Status = bookingGroup.Key.FinancialStatus,
            InvType = bookingGroup.Key.InvType
        }; 
    
    • 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 UIControl { public string FName{ get; set;
I have the following class: public class Movie { string Name get; set; string
I have the following class: public class EmailData { public string FirstName{ set; get;
I have the following class public class MenuVeiculo { public string Nome { get;
I have the following class public class CountrySpecificPIIEntity { public string Country { get;
I have the following class public class CountrySpecificPIIEntity { public string Country { get;
I have following class: class A { public IEnumerable Song { get; set; }
I have the following class: public class City { public string Name { get;
I have the following class: public class Topic { public string Topic { get;
I have the following class public class Account { IEnumerable<AccountData> Data { get; set;

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.