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