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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:45:46+00:00 2026-06-18T01:45:46+00:00

I want to retrieve commissions with a certain order number. This works: var expression

  • 0

I want to retrieve commissions with a certain order number.

This works:

var expression = from commission in db.Auftraege 
                         where commission.Auftragsnummer == orderNbr
                         select new Commission() { EF_Commission = (commission as Auftrag) };

return expression.ToList();

However, if i transform this to use a dynamic where clause (because i want to apply some more filters), the where-clause does not seem to be applied. Instead, all commissions are returned instead of only those with a specific number:

//base query
var expression = from commission in db.Auftraege select new Commission() { EF_Commission = (commission as Auftrag) };

//now add a where clause if the input parameter was specified
if (orderNbr >= 0)
    expression.Where(commission => commission.EF_Commission.Auftragsnummer == orderNbr);

 return expression.ToList();

I have looked at a dozen examples but they all seem to do it this way. Does anybody have an idea why the second query ignores the where clause?

  • 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-18T01:45:47+00:00Added an answer on June 18, 2026 at 1:45 am

    You need to assign the interim expression to something (perhaps to itself). expression.Where() does not alter the existing query – it returns a new one.

    So:

    expression = expression.Where(...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve random rows from table but this rows must be order
I have a HTML table as follows. I want retrieve row values from this
I want to retrieve IndiaRoute and 919820673883 from this URL . How can i
I want to retrieve data from the database. The number of data is fixed
I want to retrieve a number from a string wherever the number starts with
i want to retrieve the phone number from a contact name. so i have
I want to retrieve all ids within a certain timespan. The timestamps however, are
I want to retrieve website title from webview cookies of my application. I am
I want to retrieve data from two different tables depending of the value of
I want to retrieve a data which has user id 1 from the table

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.