77fa73c4548412568c61a65f6f91f91fc17b1274
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Common / EntitySql / ParseResult.cs
1 //---------------------------------------------------------------------
2 // <copyright file="ParseResult.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9
10 namespace System.Data.Common.EntitySql
11 {
12     using System.Collections.Generic;
13     using System.Data.Common.CommandTrees;
14     using System.Data.Common.EntitySql;
15     using System.Data.Common.Utils;
16     using System.Data.Metadata.Edm;
17     using System.Diagnostics;
18
19     /// <summary>
20     /// Entity SQL Parser result information.
21     /// </summary>
22     public sealed class ParseResult
23     {
24         private readonly DbCommandTree _commandTree;
25         private readonly System.Collections.ObjectModel.ReadOnlyCollection<FunctionDefinition> _functionDefs;
26
27         internal ParseResult(DbCommandTree commandTree, List<FunctionDefinition> functionDefs)
28         {
29             EntityUtil.CheckArgumentNull(commandTree, "commandTree");
30             EntityUtil.CheckArgumentNull(functionDefs, "functionDefs");
31
32             this._commandTree = commandTree;
33             this._functionDefs = functionDefs.AsReadOnly();
34         }
35
36         /// <summary>
37         /// A command tree produced during parsing.
38         /// </summary>
39         public DbCommandTree CommandTree { get { return _commandTree; } }
40
41         /// <summary>
42         /// List of <see cref="FunctionDefinition"/> objects describing query inline function definitions.
43         /// </summary>
44         public System.Collections.ObjectModel.ReadOnlyCollection<FunctionDefinition> FunctionDefinitions { get { return this._functionDefs; } }
45     }
46
47     /// <summary>
48     /// Entity SQL query inline function definition, returned as a part of <see cref="ParseResult"/>.
49     /// </summary>
50     public sealed class FunctionDefinition
51     {
52         private readonly string _name;
53         private readonly DbLambda _lambda;
54         private readonly int _startPosition;
55         private readonly int _endPosition;
56
57         internal FunctionDefinition(string name, DbLambda lambda, int startPosition, int endPosition)
58         {
59             Debug.Assert(name != null, "name can not be null");
60             Debug.Assert(lambda != null, "lambda cannot be null");
61
62             this._name = name;
63             this._lambda = lambda;
64             this._startPosition = startPosition;
65             this._endPosition = endPosition;
66         }
67
68         /// <summary>
69         /// Function name.
70         /// </summary>
71         public string Name { get { return this._name; } }
72
73         /// <summary>
74         /// Function body and parameters.
75         /// </summary>
76         public DbLambda Lambda { get { return this._lambda; } }
77
78         /// <summary>
79         /// Start position of the function definition in the eSQL query text.
80         /// </summary>
81         public int StartPosition { get { return this._startPosition; } }
82
83         /// <summary>
84         /// End position of the function definition in the eSQL query text.
85         /// </summary>
86         public int EndPosition { get { return this._endPosition; } }
87     }
88 }