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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:56:59+00:00 2026-05-14T01:56:59+00:00

If you create a Filter object that contains criteria for Linq that normally goes

  • 0

If you create a Filter object that contains criteria for Linq that normally goes in a where clause like this:

 var myFilterObject = FilterFactory.GetBlank();
 myFilterObject.AddCondition("Salary", "lessThan", "40000");

 var myResult = myRepository.GetEmployees(myFilterObject);

How would you match the Linq field to the Field Name without using a big case statement?

 return from e in db.Employee
        where e.Salary < 40000
        select new IList<EmployeeViewModel> { Name= e.name, Salary= e.Salary };

I assume you need to send an object to the Repository that specifies filtering so that you only pull what records you need. I assume Linq doesn’t pre-compile (unless you create a customized delegate and function), so you should be able to dynamically specify which fields you want to filter.

It would be nice if you could do something like e[“Salary”] like some type of Expando Object.

  • 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-14T01:56:59+00:00Added an answer on May 14, 2026 at 1:56 am

    I suggest you have a look at Dynamic Query in the Linq to SQL examples. You can use that to write conditions in “plain text”, e.g.:

    var employees = db.Employee.Where("Salary < 40000").Select(...);
    

    To clarify: These extensions essentially build the same expression trees out of the string that you normally construct via lambdas, so this isn’t the same as writing raw SQL against the database. The only disadvantage is that you can’t use the query comprehension syntax (from x in y etc.) with it.

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

Sidebar

Related Questions

I am thinking to create a filter object which filters and delete everything like
Is it possible to create a filter in a Drupal 6 View that is
This is tricky to explain. We have a DataTable that contains a user configurable
I want to create dynamic lambda expressions so that I can filter a list
I have a view that I pass a viewmodel object to that contains an
My goal is to create a single object in powershell that shows the AD
In my django views i have the following def create(request): query=header.objects.filter(id=a)[0] a=query.criteria_set.all() logging.debug(a.details) I
Will the following filter create an arbitrary shape? filter(product.product*store.store, my_measure>1.0) We place it in
How to create Photoshop Stamp filter analog in any pixel shading language? (I need
I'm trying to create specific custom filter effects on image for iOS. So far,

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.