DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ExpressionReferenceExplorer.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System.Collections.Generic;
18 
20 
21 namespace Deveel.Data.Sql.Query {
23  public static IEnumerable<ObjectName> AllReferences(this SqlExpression expression) {
24  var discover = new ReferenceDiscover();
25  discover.Visit(expression);
26  return discover.References.ToArray();
27  }
28 
29  #region ReferenceDiscover
30 
32  public ReferenceDiscover() {
33  References = new List<ObjectName>();
34  }
35 
36  public List<ObjectName> References { get; private set; }
37 
39  References.Add(reference.ReferenceName);
40  return base.VisitReference(reference);
41  }
42 
44  var value = constant.Value;
45  // TODO: if this is an array ...
46 
47  return base.VisitConstant(constant);
48  }
49  }
50 
51  #endregion
52  }
53 }
ObjectName ReferenceName
Gets the name of the object referenced by the expression.
An expression that references an object within a context.
A query to the database to select data from a set of tables and columns.
static IEnumerable< ObjectName > AllReferences(this SqlExpression expression)
override SqlExpression VisitConstant(SqlConstantExpression constant)
DataObject Value
Gets the constant value of the expression.
An expression that holds a constant value.
override SqlExpression VisitReference(SqlReferenceExpression reference)
Defines the base class for instances that represent SQL expression tree nodes.