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
  • 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-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 an Interface called IStep that can do some computation (See Execution in
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
Lets say you have interface definition. That interface can be Operation . Then you
Say I have the following interface that I want to share between my server
I have a very thin interface that's going to define one method. Should I
I have to use functionality that is in another application domain. The result should
I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items
I have an interface that I have defined in C++ which now needs to
I have an interface that needs to react to long key presses. That means

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.