Combining two expressions (Expression>)

前端 未结 7 1557
无人共我
无人共我 2020-11-22 01:09

I have two expressions of type Expression> and I want to take to OR, AND or NOT of these and get a new expression of the same type

7条回答
  •  臣服心动
    2020-11-22 01:56

    I think this works fine, isn't it ?

    Func expr1 = (x => x.Att1 == "a");
    Func expr2 = (x => x.Att2 == "b");
    Func expr1ANDexpr2 = (x => expr1(x) && expr2(x));
    Func expr1ORexpr2 = (x => expr1(x) || expr2(x));
    Func NOTexpr1 = (x => !expr1(x));
    

提交回复
热议问题