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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:32:27+00:00 2026-06-02T22:32:27+00:00

The documentation has an example about grouping on multiple properties: Dim custRegionQuery = From

  • 0

The documentation has an example about grouping on multiple properties:

Dim custRegionQuery = From cust In db.Customers _
    Group cust.ContactName By Key = New With _
        {cust.City, cust.Region} Into grouping = Group

For Each grp In custRegionQuery
    Console.WriteLine(vbNewLine & "Location Key: {0}", grp.Key)
    For Each listing In grp.grouping
        Console.WriteLine(vbTab & "{0}", listing)
    Next
Next

Suppose I have a real type (i.e. not anonymous) that has properties for each element of the key, as well as a property for the group, so something a little like:

Public Class CustomerRegionGroup

    Public Sub New(city As String, region as String, customers As IEnumerable(Of Customer))
        Me.City = city
        Me.Region = region
        Me.Customers = customers
    End Sub

    Public Property City As String
    Public Property Region As String
    Public Property Customers As IEnumerable(Of Customer)
End Class

Is it possible to rewrite the original query to just return IEnumerable(Of CustomerRegionGroup), or do I have to use the anonymous type, and run a second query on the result of the first?

  • 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-02T22:32:30+00:00Added an answer on June 2, 2026 at 10:32 pm

    Turns out it was a lot simpler than some of the things I’d tried, as I didn’t appreciate that you could just do:

    Dim custRegionQuery = From cust In db.Customers _
                          Group By cust.City, cust.Region _
                          Into Group _
                          Select New CustomerRegionGroup(City, Region, Group)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following Apple's documentation about Relationships . In their example, a Department has a
I see the Nginx HttpRewriteModule documentation has an example to rewrite a www-prefixed domain
For example, NSString documentation has – initWithFormat: – initWithFormat:arguments: – initWithFormat:locale: – initWithFormat:locale:arguments: –
I know that there has to be quite a lot of documentation about this
At the bottom of Kernel#sprintf 's documentation it has this example: sprintf(%u, -123) #=>
The documentation has the following code var options = { host: 'www.google.com', port: 80,
One again Microsoft poor documentation has left me confused. I am trying to use
The documentation below is for a module, which has now been decommissioned and I'm
Constructor for PHP's exception has third parameter, documentation says: $previous: The previous exception used
I really like the way Eclipse has pop-up Javadoc documentation for the various Java

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.