Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Common / EntitySql / AST / QueryParameter.cs
1 //---------------------------------------------------------------------
2 // <copyright file="QueryParameter.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner  [....]
7 // @backupOwner [....]
8 //---------------------------------------------------------------------
9
10 namespace System.Data.Common.EntitySql.AST
11 {
12     using System;
13
14     /// <summary>
15     /// Represents an ast node for a query parameter.
16     /// </summary>
17     internal sealed class QueryParameter : Node
18     {
19         private readonly string _name;
20
21         /// <summary>
22         /// Initializes parameter
23         /// </summary>
24         /// <remarks>
25         /// <exception cref="System.Data.EntityException">Thrown if the parameter name does not conform to the expected format</exception>
26         /// </remarks>
27         internal QueryParameter(string parameterName, string query, int inputPos)
28             : base(query, inputPos)
29         {
30             _name = parameterName.Substring(1);
31
32             //
33             // valid parameter format is: @({LETTER})(_|{LETTER}|{DIGIT})*
34             //
35             if (_name.StartsWith("_", StringComparison.OrdinalIgnoreCase) || Char.IsDigit(_name, 0))
36             {
37                 throw EntityUtil.EntitySqlError(ErrCtx, System.Data.Entity.Strings.InvalidParameterFormat(_name));
38             }
39         }
40
41         /// <summary>
42         /// Returns parameter parameterName (without @ sign).
43         /// </summary>
44         internal string Name
45         {
46             get { return _name; }
47         }
48     }
49 }