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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:32:16+00:00 2026-05-20T06:32:16+00:00

Got a table with column names as such Name | ProductID | Price |

  • 0

Got a table with column names as such

Name | ProductID | Price | Category | SubCategory

I am passing a category name into an action method and I want to return the subcategory names that are on the same row as the category name that is passed in.

So something like this, except this is wrong:

var subcategories = 
      productsRepository.Products
                        .Select(x => x.SubCategory.Where(x.Category == category);

So I can then collect the distinct subcategory names with this:

foreach (string subcategoryName in subcategories.Distinct().OrderBy(x => x))

Thanks.

  • 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-20T06:32:17+00:00Added an answer on May 20, 2026 at 6:32 am

    Are you looking for:

    var subcategories = productsRepository.Products
                                          .Where(x => x.Category == category)
                                          .Select(x => x.SubCategory)
                                          .Distinct()
                                          .OrderBy(x => x);
    

    On another note, it does appear that your database isn’t normalized.

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

Sidebar

Related Questions

Let's say you've got a table with a timestamp column, and you want to
I have got SQL Server database in which Table column name have spaces. For
I've got table with two columns: name and grade. It looks sth like this:
I'm using PHPMyAdmin and I've got a MySQL table column called timestamp. The type
I've got this table with an int(11) column and hundreds of millions of rows.
I've got a column oriented table that specifies manufacturing options for a product. Each
So I've got a column in a table that contains a string values (keywords
I've got a table one column of which uses an NSPopUpButtonCell. Try as I
In Oracle, given a list of table names, I want to perform 'select column1
I've got the following column names that I need to order by the date

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.