Dynamically building a expression object RRS feed

  • Question

  • Hello,

    I'm new to using Expressions in C#. I've four predicates. I need to dynamically build the expression object as:

    var myExpressObject = Predicate1 And !Predicate2 And !Predicate3 And 
    I tried as following but don't know how to proceed further on this :

    Expression<Func<T, bool>> expObject = x => true;
    expObject = expObject.And((Expression<Func<T, bool>>)Predicate1);


    Friday, May 25, 2018 11:24 PM

All replies

  • https://www.c-sharpcorner.com/UploadFile/c42694/dynamic-query-in-linq-using-predicate-builder/

    Maybe, it will help you.

    Friday, May 25, 2018 11:36 PM