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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:14:32+00:00 2026-06-11T18:14:32+00:00

After many hours of googling and searching stackoverflow, I desperately need your help concerning

  • 0

After many hours of googling and searching stackoverflow, I desperately need your help concerning an issue with Linq.

Imagine two tables:

Table A : Products

ID(int)     | ProductName(varchar(50))
1___________|_______________A
2___________|_______________B
3___________|_______________C
...

Table B : ProductFeatures

ProductID(int)        | FeatureID(int)                | FeatureValue(smallint)
1_____________________|_________1_____________________|____________1
1_____________________|_________2_____________________|____________1  
1_____________________|_________3_____________________|____________0
2_____________________|_________1_____________________|____________0
2_____________________|_________2_____________________|____________1
3_____________________|_________1_____________________|____________1
3_____________________|_________2_____________________|____________1
...

E.g.

FeatureID = 1 => "has WiFi" 
FeatureValue 1 = Yes / 0 = No.

Table C: I also have a Feature description table

FeatureID int, 
FeatureName varchar(50)

In my ASP application, I have a panel that contains controls like checkboxes/dropdownlists and allows the user to filter the list of Products.

So, if someone selects the ‘Laptops’ category, the page will display the list of laptops and furthermore he can click filters like “with WiFi” checkbox etc in order to narrow down the results.

My problem:

First, the Filter controls populate a List which contains the FeatureIDs that were requested:

List<int> filters=getFilterPanelList(); 

How can I Select all the Products from the Products table WHERE the Product’s features will contain at least the filters List? (in SQL or Linq script).

For example: if the controls produce the list (1,3) then the Linq query will return only the product 1 because it contains at least the 1 and 3 FeatureIDs.

I found something like the bellow SQL query but the ‘IN’ operator (or the ‘Contains’ function in Linq) returns all the products that contains FeatureID 1 or FeatureID 3 but not both of them:

SELECT ProductID 
FROM 
    Products P
    JOIN ProductFeatures PF ON PF.ProductID = P.ID
WHERE 
    PF.ProductID IN

SELECT ProductID 
FROM 
    ProductFeatures 
WHERE 
    FeatureID IN @FilterList)"
  • 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-11T18:14:34+00:00Added an answer on June 11, 2026 at 6:14 pm

    In Linq:

    from p in products
    where p.ProductFeatures.Count(pf => filters.Contains(pf.FeatureID)) == filters.Count
    select p
    

    I assumed one product has not more then one feature of the same type.

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

Sidebar

Related Questions

After many hours of hair pulling, I look to stackoverflow to help me solve
After googling for many hours for a solution for the above Sharepoint exception, I
After many hours spent on reading documentations and searching for some tips on the
After many hours of googling I thought I would see if anyone knew the
After many hours wasted, I officially turn to the experts for help! My problem
After many hours of searching and reading articles I am not able to call
After many hours of research and tinkering, I've finally managed to get backbone.js routes
im trying to customize this page indicator with half succes, but after many hours
I need to delete coma(,) after so many. Say there a string with 4
After one week searching and converting many algorithm from other language into php to

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.