创建具有多个 OR 和 AND 条件的 LINQ 表达式树

Create LINQ expression Tree with multiple OR and AND condition

我想生成具有嵌套 AND 或 OR 条件的 LINQ 表达式树。我有以下表情

    var constant = Expression.Constant("Jhon");
    var property = Expression.Property(paramExpr,"FirstName");
    var expression = Expression.Equal(property, constant);
    constant = Expression.Constant("12");
    property = Expression.Property(paramExpr, "Age");
    var expression2 = Expression.Equal(property, constant);

    expressionMain1 = Expression.AND(expression, expression2);

    constant = Expression.Constant("Mathew");
    property = Expression.Property(paramExpr,"LastName");
    expression = Expression.Equal(property, constant);
    constant = Expression.Constant("19");
    property = Expression.Property(paramExpr, "Age");
    expression2 = Expression.Equal(property, constant);

    expressionMain2 = Expression.And(expression, expression2);

我想要像这样的最终 lambda 查询

(FirstName='John' AND Age='12') OR (LastName='Mathew' AND Age= '19')

这样可以吗?

Expression.OrElse(expressionMain1, expressionMain2)