1 //---------------------------------------------------------------------
2 // <copyright file="QueryParameter.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 //---------------------------------------------------------------------
10 namespace System.Data.Common.EntitySql.AST
15 /// Represents an ast node for a query parameter.
17 internal sealed class QueryParameter : Node
19 private readonly string _name;
22 /// Initializes parameter
25 /// <exception cref="System.Data.EntityException">Thrown if the parameter name does not conform to the expected format</exception>
27 internal QueryParameter(string parameterName, string query, int inputPos)
28 : base(query, inputPos)
30 _name = parameterName.Substring(1);
33 // valid parameter format is: @({LETTER})(_|{LETTER}|{DIGIT})*
35 if (_name.StartsWith("_", StringComparison.OrdinalIgnoreCase) || Char.IsDigit(_name, 0))
37 throw EntityUtil.EntitySqlError(ErrCtx, System.Data.Entity.Strings.InvalidParameterFormat(_name));
42 /// Returns parameter parameterName (without @ sign).