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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:25:38+00:00 2026-06-02T07:25:38+00:00

Example scenario: Two tables: order and orderItem , relationship One to Many. I want

  • 0

Example scenario:
Two tables: order and orderItem, relationship One to Many.
I want to select all orders that have at least one orderItem with price 100 and at least one orderItem with price 200.
I can do it like this:

var orders = (from o in kontextdbs.orders
              join oi in kontextdbs.order_item on o.id equals oi.order_id
              join oi2 in kontextdbs.order_item on o.id equals oi2.order_id
              where oi.price == 100 && oi2.price  == 200
              select o).Distinct();      

But what if those conditions are user generated?
So I dont know how many conditions there will be.

  • 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-02T07:25:40+00:00Added an answer on June 2, 2026 at 7:25 am

    You need to loop through all the values using a Where and Any method like this:

    List<int> values= new List() { 100, 200 };
    
    var orders = from o in kontextdbs.orders
                 select o;
    foreach(int value in values)
    {    
          int tmpValue = value;
          orders = orders.Where(x => kontextdbs.order_item.Where(oi => x.id == oi.order_id)
                                                          .Any(oi => oi.price == tmpValue));    
    }
    
    orders = orders.Distinct();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario I have 3 database tables. One is for Images and the other two
Common scenario: I have a library that uses other libraries. For example, a math
Let me explain the situation I have two tables: -One is to store the
I have a CATEGORIES table that links to an ITEMS table (one to many).
I have two database tables (lets call them A and B) with many-to-many bridge
I am trying to create a generic formatter/parser combination. Example scenario: I have a
Example: I have an class that inherits from UIImageView. An object creates an instance
Hibernate mapping question where the behavior is ambiguous and/or dangerous. I have a one-to-many
I have two tables Table1: ColumnA (varchar) Table2: ColumnB (varchar) I need to get
The Scenario I have a table on a web page that is dynamically generated

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.