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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:03:25+00:00 2026-05-10T22:03:25+00:00

Starting with the following LINQ query: from a in things where a.Id == b.Id

  • 0

Starting with the following LINQ query:

from a in things   where a.Id == b.Id &&   a.Name == b.Name &&   a.Value1 == b.Value1 &&   a.Value2 == b.Value2 &&   a.Value3 == b.Value3   select a; 

How can I remove (at runtime) one or more of the conditions in the where clause in order to obtain queries similar to the following ones:

from a in things   where a.Id == b.Id &&   a.Name == b.Name &&   a.Value2 == b.Value2 &&   a.Value3 == b.Value3   select a; 

Or

from a in things   where  a.Name == b.Name &&   a.Value3 == b.Value3   select a; 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:03:26+00:00Added an answer on May 10, 2026 at 10:03 pm

    Rather than try to change existing where clauses, I’d refactor it to this:

    from a in things   where a.Id == b.Id  where a.Name == b.Name  where a.Value1 == b.Value1 where a.Value2 == b.Value2 where a.Value3 == b.Value3   select a; 

    That then becomes:

    things.Where(a => a.Id == b.Id)       .Where(a => a.Name == b.Name)       .Where(a => a.Value1 == b.Value1)       .Where(a => a.Value2 == b.Value2)       .Where(a => a.Value1 == b.Value3); 

    Now it should be reasonably clear how to proceed – conditionalise the calls to Where:

    IQueryable<Whatever> query = things; if (useId) {     query = query.Where(a => a.Id == b.Id); } query = query.Where(a => a.Name == b.Name); if (checkValue1) {     query = query.Where(a => a.Value1 == b.Value1); } // etc 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following LINQ query that returns two objects from my database. These
I'm having trouble converting the following SQL-statement to LINQ-to-entities: SELECT l.* FROM locations l
What is the most elegant way of getting the following: Starting from today's date,
I have the following Linq to Objects query: var query = this._vaporizerData .Where(row =>
The following query is something i inherited from an old app that adds 2
I am just starting to learn LINQ. I wrote the following linq expression to
I'm getting the following error when trying to do a linq query: LINQ to
Starting with the following array (of hashes): [ {:name=>site a, :url=>http://example.org/site/1/}, {:name=>site b, :url=>http://example.org/site/2/},
Iam an F# newbie, I have following starting point: type aB = { ID:
Im starting with XNA and i need an advice about the following. I have

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.