1 //---------------------------------------------------------------------
2 // <copyright file="ParseResult.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 //---------------------------------------------------------------------
10 namespace System.Data.Common.EntitySql
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;
20 /// Entity SQL Parser result information.
22 public sealed class ParseResult
24 private readonly DbCommandTree _commandTree;
25 private readonly System.Collections.ObjectModel.ReadOnlyCollection<FunctionDefinition> _functionDefs;
27 internal ParseResult(DbCommandTree commandTree, List<FunctionDefinition> functionDefs)
29 EntityUtil.CheckArgumentNull(commandTree, "commandTree");
30 EntityUtil.CheckArgumentNull(functionDefs, "functionDefs");
32 this._commandTree = commandTree;
33 this._functionDefs = functionDefs.AsReadOnly();
37 /// A command tree produced during parsing.
39 public DbCommandTree CommandTree { get { return _commandTree; } }
42 /// List of <see cref="FunctionDefinition"/> objects describing query inline function definitions.
44 public System.Collections.ObjectModel.ReadOnlyCollection<FunctionDefinition> FunctionDefinitions { get { return this._functionDefs; } }
48 /// Entity SQL query inline function definition, returned as a part of <see cref="ParseResult"/>.
50 public sealed class FunctionDefinition
52 private readonly string _name;
53 private readonly DbLambda _lambda;
54 private readonly int _startPosition;
55 private readonly int _endPosition;
57 internal FunctionDefinition(string name, DbLambda lambda, int startPosition, int endPosition)
59 Debug.Assert(name != null, "name can not be null");
60 Debug.Assert(lambda != null, "lambda cannot be null");
63 this._lambda = lambda;
64 this._startPosition = startPosition;
65 this._endPosition = endPosition;
71 public string Name { get { return this._name; } }
74 /// Function body and parameters.
76 public DbLambda Lambda { get { return this._lambda; } }
79 /// Start position of the function definition in the eSQL query text.
81 public int StartPosition { get { return this._startPosition; } }
84 /// End position of the function definition in the eSQL query text.
86 public int EndPosition { get { return this._endPosition; } }