sdk/dotnet/src/Microsoft.Datasync.Client/Query/OData/ODataExpressionParser.cs
/// <summary>
/// Parses a type coercion statement.
/// </summary>
/// <param name="errorPos">The start of the function call.</param>
/// <returns>A <see cref="QueryNode"/> that represents the statement</returns>
Parses a type coercion statement.
Parses a type coercion statement .
private QueryNode ParseTypeCoercion(int errorPos)
        {
            ValidateTokenIsType(QueryTokenKind.OpenParen, "'(' expected.");
            QueryToken token = lexer.ReadUntilCharacter(')');
            string[] arguments = token.Text.Split(',').Select(arg => arg.Trim()).ToArray();
            if (arguments.Length != 2)
            {
                throw new ODataException("Invalid cast (args != 2)", lexer.Text, errorPos);
            }
            QueryNode node;
            try
            {
                node = EdmTypeSupport.ToQueryNode(arguments[0], arguments[1]);
            }
            catch (Exception ex)
            {
                throw new ODataException("Invalid cast", ex, lexer.Text, errorPos);
            }
            lexer.NextToken();
            ValidateTokenIsType(QueryTokenKind.CloseParen, "')' expected.");
            lexer.NextToken();
            return node;
        }
private QueryNode ParseTypeCoercion ( int errorPos ) { ValidateTokenIsType ( QueryTokenKind . OpenParen , " " ) ; QueryToken token = lexer . ReadUntilCharacter ( ' ' ) ; string [ ] arguments = token . Text . Split ( ' ' ) . Select ( arg => arg . Trim ( ) ) . ToArray ( ) ; if ( arguments . Length != 2 ) { throw new ODataException ( " " , lexer . Text , errorPos ) ; } QueryNode node ; try { node = EdmTypeSupport . ToQueryNode ( arguments [ 0 ] , arguments [ 1 ] ) ; } catch ( Exception ex ) { throw new ODataException ( " " , ex , lexer . Text , errorPos ) ; } lexer . NextToken ( ) ; ValidateTokenIsType ( QueryTokenKind . CloseParen , " " ) ; lexer . NextToken ( ) ; return node ; }
Parses a type coercion statement.
Parses a type coercion statement .
// Construct the call, crudely. // This should be the close parens.
A  that represents the statement
A that represents the statement
errorPos
int
The start of the function call.
The start of the function call .