Skip to content

Commit

Permalink
Added Linq-to-BsonExpression mapping for non-short-circuit 'AND' and …
Browse files Browse the repository at this point in the history
…'OR'
  • Loading branch information
lbnascimento committed Apr 15, 2020
1 parent 4fe3afc commit 21779c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LiteDB.Tests/Mapper/LinqBsonExpression_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ public void Linq_Predicate()
TestPredicate<User>(x => x.Salary != 50, "(Salary != @p0)", 50);
TestPredicate<User>(x => x.Salary == x.Id, "(Salary = _id)");
TestPredicate<User>(x => x.Salary > 50 && x.Name == "John", "((Salary > @p0) AND (Name = @p1))", 50, "John");
TestPredicate<User>(x => x.Salary > 50 & x.Name == "John", "((Salary > @p0) AND (Name = @p1))", 50, "John");
TestPredicate<User>(x => x.Salary > 50 || x.Name == "John", "((Salary > @p0) OR (Name = @p1))", 50, "John");
TestPredicate<User>(x => x.Salary > 50 | x.Name == "John", "((Salary > @p0) OR (Name = @p1))", 50, "John");

// unary expressions
TestPredicate<User>(x => x.Active, "(Active = true)");
Expand Down
2 changes: 2 additions & 0 deletions LiteDB/Client/Mapper/Linq/LinqExpressionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@ private string GetOperator(ExpressionType nodeType)
case ExpressionType.GreaterThanOrEqual: return " >= ";
case ExpressionType.LessThan: return " < ";
case ExpressionType.LessThanOrEqual: return " <= ";
case ExpressionType.And: return " AND ";
case ExpressionType.AndAlso: return " AND ";
case ExpressionType.Or: return " OR ";
case ExpressionType.OrElse: return " OR ";
}

Expand Down

1 comment on commit 21779c1

@lbnascimento
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1633

Please sign in to comment.