Remotion.Linq.SqlBackend.MappingResolution.SqlContextExpressionVisitor.HandlePredicateSemantics C# (CSharp) Method

HandlePredicateSemantics() private method

private HandlePredicateSemantics ( Expression expression ) : Expression
expression System.Linq.Expressions.Expression
return System.Linq.Expressions.Expression
    private Expression HandlePredicateSemantics (Expression expression)
    {
      var newExpression = base.VisitExpression (expression);

      var convertedBooleanExpression = newExpression as SqlConvertedBooleanExpression;
      if (convertedBooleanExpression != null)
      {
        var isNullableExpression = convertedBooleanExpression.Expression.Type == typeof (int?);
        return Expression.Equal (convertedBooleanExpression.Expression, new SqlLiteralExpression (1, isNullableExpression), isNullableExpression, null);
      }

      if (!BooleanUtility.IsBooleanType (newExpression.Type))
      {
        var message = string.Format (
            "Cannot convert an expression of type '{0}' to a boolean expression. Expression: '{1}'", 
            newExpression.Type, 
            FormattingExpressionTreeVisitor.Format(expression));
        throw new NotSupportedException (message);
      }

      return newExpression;
    }