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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:56:34+00:00 2026-05-24T05:56:34+00:00

I am moving a project from working with standard DB queries to working with

  • 0

I am moving a project from working with standard DB queries to working with EF and LINQ. I have a table that has certain records that I would use to build a query that would look like the following:

select * from client where city = ?

In my original table, I would be pulling client and city from the table to build that query.

It is also possible that client and city above could be another table and/or field altogether. How would I do the same thing with EF and LINQ? Is this even possible or do I have to build a separate class to handle all of that logic?

var query = from c in context.clients
            where c.city == ?
            select c;

Edit: This isn’t about joining queries. It’s about building dynamic queries. I don’t know when I run the program whether I will be querying on city, address, or any even on the “client” table itself. It could be on another table. I want to be able to dynamically build the queries.

  • 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-24T05:56:34+00:00Added an answer on May 24, 2026 at 5:56 am

    If you want to build dynamic queries in Entity Framework, you CAN go through the trouble of trying to build the expression tree dynamically. However, the Entity Framework gives you some additional options.

    First, EntityObject has some additional Object Services methods which already let you build a string and pass that in directly into a number of the predicates, including Where:

    c.Customers.Where("City = 'London'");
    

    If you need to build larger queries, including dynamically setting the query source, consider using EntitySQL. For example with EntitySQL, you can use simple string parsing and generate code like the following:

    string entitySQL = "SELECT VALUE c FROM Customers AS c WHERE c.Address.City = 'Seattle';";
    ObjectQuery<Customer> query = context.CreateQuery<Customer>(entitySQL);
    

    You can see both of these options in action in the Entity Framework Query Samples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a project that is moving from .NET 2.0 to
Basically, I have a project I've been working on for a while, and would
We are considering moving from ClearCase to Subversion. The project has been there for
I am working on a web app project that has been in development for
I am working on a project that has a simulated robot exploring an unknown,
Moving a working C# project from a 64-bit Windows 7 machine to a 32-bit
I'm working on a project with many unknowns like moving the app from one
Before moving on to use SVN, I used to manage my project by simply
Working on calling a C function from my asm project. I'm trying to push
I am working on a project that includes a Mac application and an iPad

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.