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

  • Home
  • SEARCH
  • 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 6707333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:37:36+00:00 2026-05-26T07:37:36+00:00

I am writing a small console and I want the user to specify a

  • 0

I am writing a small console and I want the user to specify a field and a value to search for. Unfortunately, I can’t seem to specify the field name in my linq to Sql query. It should be possible, as the list of fields do exist somewhere. Rather than try to explain it, here’s what I would like to do:

...
if (!String.IsNullOrEmpty(filterCriteria.OrderNumberEnd)) query = from o in query where o.orderDate <= filterCriteria.OrderDateEnd select o;

if (!String.IsNullOrEmpty(filterCriteria.OrderNumberStart)) query = from o in query where o.orderDate >= filterCriteria.OrderDateStart select o;

if (!String.IsNullOrEmpty(filterCriteria.Keyword) && !String.IsNullOrEmpty(filterCriteria.Field)) 
    query = query.Where(String.Format("{0}={1}", filterCriteria.Keyword, filterCriteria.Field);

The last line is doesn’t work, can it work or is this a limitation to linq to sql?

  • 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-26T07:37:36+00:00Added an answer on May 26, 2026 at 7:37 am

    You will need dynamic LINQ in order to accomplish that. It does not come out of the box.

    http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

    http://blog.bvsoftware.com/post/2008/02/27/How-to-create-a-Dynamic-LINQ-Query-Programmatically.aspx

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

Sidebar

Related Questions

I'm trying to practice my F# by writing small console scripts in F# in
I am writing a small program in Visual Studio 11 (beta) that a console
I am writing a small console application in C# that references a custom assembly
In a small console application I'm writing to test something I need to add
I have a small C# console app I am writing. I would like the
I'm writing a small program in C that will read input from the console.
I'm writing a small App in which i read some text from to console,
I am writing small social application. One of the features is to write user
I'm writing a small c# console application that needs to interogate Websphere Application Server
I have a java console app that I'm writing, and I want people to

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.