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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:40:26+00:00 2026-05-24T13:40:26+00:00

I have a interface in that user indicates some elements and operators between them

  • 0

I have a interface in that user indicates some elements and operators between them and I should display the result.

User can build then a filter like p1 OP v1 OR p2 OP v2 where p1 and p2 are Person properties, like Age, Name, Location etc, v1 and v2 are comparative values(10, ‘Maria’, ‘L.A.’), OP are comparison operators (=, <, >) and OR is a logical operator(can be also AND).

Eg:
Age > 18 AND Location = 'Paris', or another one like
Name Contains 'andro' AND Sex = 'm'

Having myPeople collection and this filter string, how can I Build and apply this expression using Linq.Expressions?

I tried to use DynamicLinq, but actually I have a problem using “Where” on List<Person>, apparently is not IQueryable…

  • 1 1 Answer
  • 2 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-24T13:40:26+00:00Added an answer on May 24, 2026 at 1:40 pm

    If you’re trying to use it with List<T>, I wouldn’t bother using expression trees to start with:

    public static Func<T, bool> Or<T>(Func<T, bool> predicate1,
                                      Func<T, bool> predicate2)
    {
        return t => predicate1(t) || predicate2(t);
    }
    
    public static Func<T, bool> And<T>(Func<T, bool> predicate1,
                                       Func<T, bool> predicate2)
    {
        return t => predicate1(t) && predicate2(t);
    }
    

    Then you can do:

    Func<Person, bool> isAdult = person => person.Age > 18;
    Func<Person, bool> isInParis = person => person.Location == "Paris";
    
    var personInParis = And(isAdult, isInParis);
    

    For the equivalent for expression trees if you want those later, look at PredicateBuilder.

    The tricky bit is likely to be converting your string into an expression tree to start with.

    If Dynamic LINQ does everything else you want, you can just use AsQueryable to create an IQueryable<T> from an IEnumerable<T>.

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

Sidebar

Related Questions

I have a fairly large application that uses WPF for its user interface. I
I have a interface that defines some methods with attributes. These attributes need to
I have an interface that defines some methods I would like certain classes to
I have a User entity which has a HasCompletedSecurity property which indicates whether that
I have a User Interface that receives asynchronous notifications from a Service that prompts
I have a client-side interface that allows the user to perform multiple edits against
I often have to deal with lists in the user interface that translate to
I have a logging interface that allows user to subclass a Logger and override
We have an unattended app w/o a user interface that is is periodically run.
So have a user interface that I wrote using MinGW QT. In the UI

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.