sdk/dotnet/src/Microsoft.Datasync.Client.SQLiteStore/Utils/SqlQueryFormatter.cs
/// <summary>
/// Visitor for a binary operator node.
/// </summary>
/// <param name="node">The incoming node.</param>
/// <returns>The processed node.</returns>
Visitor for a binary operator node.
Visitor for a binary operator node .
public override QueryNode Visit(BinaryOperatorNode node)
        {
            sql.Append('(');
            QueryNode left = node.LeftOperand;
            QueryNode right = node.RightOperand;
            if (left != null)
            {
                if (node.OperatorKind == BinaryOperatorKind.Modulo)
                {
                    left = new ConvertNode(left, typeof(int));
                }
                left = left.Accept(this);
            }
            if (right is ConstantNode rightConstant && rightConstant.Value == null)
            {
                if (node.OperatorKind == BinaryOperatorKind.Equal)
                {
                    sql.Append(" IS ");
                }
                else if (node.OperatorKind == BinaryOperatorKind.NotEqual)
                {
                    sql.Append(" IS NOT ");
                }
            }
            else
            {
                sql.Append(' ').Append(node.OperatorKind.ToSqlOperator()).Append(' ');
            }
            if (right != null)
            {
                right = right.Accept(this);
            }
            sql.Append(')');
            return (left != node.LeftOperand || right != node.RightOperand) ? new BinaryOperatorNode(node.OperatorKind, left, right) : node;
        }
public override QueryNode Visit ( BinaryOperatorNode node ) { sql . Append ( ' ' ) ; QueryNode left = node . LeftOperand ; QueryNode right = node . RightOperand ; if ( left != null ) { if ( node . OperatorKind == BinaryOperatorKind . Modulo ) { left = new ConvertNode ( left , typeof ( int ) ) ; } left = left . Accept ( this ) ; } if ( right is ConstantNode rightConstant && rightConstant . Value == null ) { if ( node . OperatorKind == BinaryOperatorKind . Equal ) { sql . Append ( " " ) ; } else if ( node . OperatorKind == BinaryOperatorKind . NotEqual ) { sql . Append ( " " ) ; } } else { sql . Append ( ' ' ) . Append ( node . OperatorKind . ToSqlOperator ( ) ) . Append ( ' ' ) ; } if ( right != null ) { right = right . Accept ( this ) ; } sql . Append ( ' ' ) ; return ( left != node . LeftOperand || right != node . RightOperand ) ? new BinaryOperatorNode ( node . OperatorKind , left , right ) : node ; }
Visitor for a binary operator node.
Visitor for a binary operator node .
The processed node.
The processed node .
node
BinaryOperatorNode
The incoming node.
The incoming node .