protected override Expression VisitUnary(UnaryExpression node) { switch (node.NodeType) { case ExpressionType.Convert: if (IsSingleBooleanProperty(node.Operand)) { HandleSingleBooleanProperty(node.Operand as MemberExpression, true); break; } if (node.Operand.Type.Is <MethodCallExpression>()) { HandleAsMethodCall(node.Operand as MethodCallExpression); break; } if (node.Type.IsEnumType() && !node.BelongsToParameter()) { WriteParameter(node); break; } var op = node.Operand as ConstantExpression; if (IsSingleBooleanConstant(op)) { HandleSingleBooleanConstant(op); return(node); } Visit(node.Operand); break; case ExpressionType.New: Visit(node.Operand); break; case ExpressionType.Not: if (node.Operand.BelongsToParameter()) { if (IsSingleBooleanProperty(node.Operand)) { HandleSingleBooleanProperty(node.Operand as MemberExpression, false); break; } } var opf = node.Operand as ConstantExpression; if (IsSingleBooleanConstant(opf)) { HandleSingleBooleanConstant(opf); return(node); } _sb.Append("not "); Visit(node.Operand); break; } return(node); }