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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:46:35+00:00 2026-05-24T07:46:35+00:00

I have a set of objects that I’m returning via a Linq to SQL

  • 0

I have a set of objects that I’m returning via a Linq to SQL query. I’d like to modify the query so that I return a set of objects that are combined only when one of the fields match.

The relevant columns of my Products DB table are CategoryID and Quantity. I’d like to combine the fields so that if the CategoryID is identical, the Quantity fields are summed up. However, I don’t just want the sum – I need an object that has all the common fields (assume all other fields are identical for the query) so it appears as only one object of type Product.

Is this possible? (I’m using VB.net – but open to solutions that include database views, partial classes, etc)

  • 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-24T07:46:35+00:00Added an answer on May 24, 2026 at 7:46 am

    It sounds like you want to Group on CategoryId and create a new Product based on aggregate data. E.g. (sorry if my VB is terrible):

    From product In db.Products _
    Group By CategoryID = product.CategoryID Into Group _
    Select New Product With _
        CategoryID = CategoryID, _
        QuantityA = Group.Select(Function(p) p.QuantityA).Sum(), _
        QuantityB = Group.Select(Function(p) p.QuantityB).Sum()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of 2 or more objects that I'd like to order.
I have a set of subclassed domain objects that I fetch with Linq and
I have an odd problem with Django. I have a set of objects that
I have an object that is mapped to have a set of objects, very
I have a class that serializes a set of objects (using XML serialization) that
I have a Rect object that I'd like to create and set its properties
I have a set of objects in a Vector from which I'd like to
I have a set of objects I'd like to do some operations on, in
I have a set of objects in Mongodb that each have a set of
I have a modeled a set of objects that correspond with some real world

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.