Permalink
Browse files

fixed ! operator to transform call into == false. Also, removed incor…

…rect implementation of operator.
  • Loading branch information...
craiggwilson authored and lanwin committed Nov 6, 2010
1 parent 485801d commit 19d04067755ccb7e4fb6adf12cd4068bdaeac716
@@ -24,7 +24,7 @@ public void Boolean_Inverse()
var people = Collection.Linq().Where(x => !x.PrimaryAddress.IsInternational);
var queryObject = ((IMongoQueryable)people).GetQueryObject();
- Assert.AreEqual(new Document("$not", new Document("PrimaryAddress.IsInternational", true)), queryObject.Query);
+ Assert.AreEqual(new Document("PrimaryAddress.IsInternational", false), queryObject.Query);
}
[Test]
@@ -138,7 +138,6 @@ protected override Expression VisitMethodCall(MethodCallExpression m)
PopConditionScope(); //elemMatch
PopConditionScope(); //field
return m;
-
case "Contains":
if (m.Arguments.Count != 2)
throw new NotSupportedException("Only the Contains method with 2 arguments is supported.");
@@ -202,6 +202,17 @@ protected override Expression VisitParameter(ParameterExpression p)
return _map.TryGetValue(p, out e) ? e : p;
}
+ protected override Expression VisitUnary(UnaryExpression u)
+ {
+ switch (u.NodeType)
+ {
+ case ExpressionType.Not:
+ return Visit(Expression.Equal(u.Operand, Expression.Constant(false)));
+ }
+
+ return u;
+ }
+
private Expression BindAggregate(Expression source, MethodInfo method, LambdaExpression argument, bool isRoot)
{
var returnType = method.ReturnType;

0 comments on commit 19d0406

Please sign in to comment.