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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:51:30+00:00 2026-05-15T19:51:30+00:00

Ok this should be really simple, but I am doing my head in here

  • 0

Ok this should be really simple, but I am doing my head in here and have read all the articles on this and tried a variety of things, but no luck.

I have 3 tables in a classic many-to-many setup.

ITEMS
ItemID
Description

ITEMFEATURES
ItemID
FeatureID

FEATURES
FeatureID
Description

Now I have a search interface where you can select any number of Features (checkboxes).
I get them all nicely as an int[] called SearchFeatures.

I simply want to find the Items which have the Features that are contained in the SearchFeatures.

E.g. something like:

return db.Items.Where(x => SearchFeatures.Contains(x.ItemFeatures.AllFeatures().FeatureID))

Inside my Items partial class I have added a custom method Features() which simply returns all Features for that Item, but I still can’t seem to integrate that in any usable way into the main LINQ query.

Grr, it’s gotta be simple, such a 1 second task in SQL. Many 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-15T19:51:31+00:00Added an answer on May 15, 2026 at 7:51 pm

    The following query will return the list of items based on the list of searchFeatures:

    from itemFeature in db.ItemFeatures
    where searchFeatures.Contains(itemFeature.FeatureID)
    select itemFeature.Item;
    

    The trick here is to start with the ItemFeatures table.


    It is possible to search items that have ALL features, as you asked in the comments. The trick here is to dynamically build up the query. See here:

    var itemFeatures = db.ItemFeatures;
    
    foreach (var temp in searchFeatures)
    {
        // You will need this extra variable. This is C# magic ;-).
        var searchFeature = temp;
    
        // Wrap the collection with a filter
        itemFeatures =
            from itemFeature in itemFeatures
            where itemFeature.FeatureID == searchFeature
            select itemFeature;
    }
    
    var items =
        from itemFeature in itemFeatures
        select itemFeature.Item;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be really simple, but I have tried many solutions posted on the
This should be really simple but what i'm doing is pulling data from a
This seems like it should be really simple, but I'm unable to figure this
This should be really simple but I can't get it to work, how do
I'm cocking this up and it should be really simple but the value of
This should be a really simple problem, but I can't quite figure out what
This should be really simple I know, but for the life of me I
Really simple question: Am I missing something? Seems like this should be all that
ok, this seems like it should be really simple but Im a bit confused:
I know this question should be really simple, but for some reason thoroughly understanding

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.