Skip to content

Commit

Permalink
refactor: use make binary
Browse files Browse the repository at this point in the history
  • Loading branch information
melflitty-aneo committed Jul 31, 2023
1 parent b6ae04f commit fd9973b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Common/src/gRPC/ExpressionExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public static Expression<Func<T, bool>> ExpressionAnd<T>(this Expression<Func<T,
parameter);
var right = rightVisitor.Visit(expr2.Body);

return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(left,
right),
return Expression.Lambda<Func<T, bool>>(Expression.MakeBinary(ExpressionType.AndAlso,
left,
right),
parameter);
}

Expand All @@ -54,8 +55,8 @@ public static Expression<Func<T, bool>> ExpressionAnd<T>(this Expression<Func<T,
/// <param name="expr1"> The first predicate expression to combine </param>
/// <param name="expr2"> The second predicate expression to combine </param>
/// <returns> A new predicate expression that represents the logical OR of the two expressions </returns>
public static Expression<Func<T, bool>> ExpressionOr<T>(this Expression<Func<T, bool>> expr1,
Expression<Func<T, bool>> expr2)
public static Expression<Func<T, bool>>? ExpressionOr<T>(this Expression<Func<T, bool>> expr1,
Expression<Func<T, bool>> expr2)
{
var parameter = Expression.Parameter(typeof(T));

Expand All @@ -67,8 +68,9 @@ public static Expression<Func<T, bool>> ExpressionOr<T>(this Expression<Func<T,
parameter);
var right = rightVisitor.Visit(expr2.Body);

return Expression.Lambda<Func<T, bool>>(Expression.OrElse(left,
right),
return Expression.Lambda<Func<T, bool>>(Expression.MakeBinary(ExpressionType.OrElse,
left,
right),
parameter);
}

Expand Down

0 comments on commit fd9973b

Please sign in to comment.