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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:22:37+00:00 2026-06-01T00:22:37+00:00

I have this expression: var result = from pav in ProductAttributes join id in

  • 0

I have this expression:

var result = from pav in ProductAttributes
           join id in valueIds
           on pav.AttributeValueID equals id
           select pav.ProductImageID;

which works up to a point. The issue is that the collection ProductAttributes contains the same product many times, for each attribute. It’s structure is:

ID – unique

ProductID

ProductAttributeValueID

ProductImageID

So a Product may appear many times in the collection. I want the result to actually filter OUT all the products that DON’T have any matches at all in valueIds (which is a list of ProductAttributeValueIDs).

So I want to ONLY return products that have ALL of the COMBINED valueIds, not just ANY of them, which is what the above linq expression is doing.

PS I can post SQL code that shows what I mean in SQL if that helps!

@devgeezer posted an answer which was close enough but it only worked for one value.

I ended up with the code below, which works. I group on the ProductID, then use that in a 2nd query to filter the original collection:

        var result = 
            from pav in ProductAttributeValues
            join id in valueIds
            on pav.AttributeValueID equals id
            group pav by pav.ProductID into gj
            where gj.Count() == valueIds.Count()
            select gj.Key;

        var imageIds = from pav in ProductAttributeValues
                       join id in result
                       on pav.ProductID equals id 
                       select pav.ProductImageID;
  • 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-01T00:22:38+00:00Added an answer on June 1, 2026 at 12:22 am

    You might try a group and filter approach something like the following:

    var result = 
        from pav in ProductAttributes
        join id in valueIds
        on pav.AttributeValueID equals id
        group pav by pav.ProductImageID into gj
        where gj.Count() == valueIds.Count()
        select gj.Key;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this regular expression: var from = result.match(/^From\:(.*)/m)[1].replace(/^\s+/, ''); The problem is that
I have this query: var accounts = from account in context.Accounts from owner in
I have a lambda expression that gets results from a Dictionary. var sortedDict =
I am getting an exception when I execute this code: var result = from
I have this Regular Expression that matches the following strings: <!-- 09-02-2009 ---> <!--
I am very confused. I have this lambda expression: tvPatientPrecriptionsEntities.Sort((p1, p2) => p1.MedicationStartDate .Value
The following code fails in 'Evaluate' with: This expression was expected to have type
Right now I have something like this in NHibernate: Expression.Like(property, value, MatchMode.Anywhere) and that
I have a nHibernate query like this ICriteria query = session.CreateCriteria(typeof(MyResult)) .Add(Expression.Eq(ResultTypeId, myResult.ResultTypeId)) Problem
I have a data that looks like this 1:SRX000566 Submitter: WoldLab Study: RNASeq expression

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.