Skip to content

Commit

Permalink
fix: Expression.And and Or is bitwise operation, should use AndAlso a…
Browse files Browse the repository at this point in the history
…nd OrElse
  • Loading branch information
doddgu committed Sep 1, 2022
1 parent 3708059 commit c2f0504
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ public static class ExpressionExtensions
{
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
{
return first.Compose(second, Expression.And);
return first.Compose(second, Expression.AndAlso);
}

public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, bool isCompose, Expression<Func<T, bool>>? second)
{
if (isCompose && second != null)
return first.Compose(second, Expression.And);
return first.Compose(second, Expression.AndAlso);

return first;
}

public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
{
return first.Compose(second, Expression.Or);
return first.Compose(second, Expression.OrElse);
}

public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, bool isCompose, Expression<Func<T, bool>>? second)
{
if (isCompose && second != null)
return first.Compose(second, Expression.Or);
return first.Compose(second, Expression.OrElse);

return first;
}
Expand Down

0 comments on commit c2f0504

Please sign in to comment.