DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ReferenceTable.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;
18 
19 namespace Deveel.Data.Sql.Tables {
21  private readonly TableInfo tableInfo;
22 
23  public ReferenceTable(ITable parent, ObjectName tableName)
24  : this(parent, parent.TableInfo.Alias(tableName)) {
25  }
26 
27  public ReferenceTable(ITable parent, TableInfo tableInfo)
28  : base(parent) {
29  TableName = tableInfo.TableName;
30  this.tableInfo = tableInfo;
31  }
32 
33  public ObjectName TableName { get; private set; }
34 
35  public override TableInfo TableInfo {
36  get { return tableInfo; }
37  }
38 
39  protected override int IndexOfColumn(ObjectName columnName) {
40  var tableName = columnName.Parent;
41  if (tableName != null && tableName.Equals(TableName))
42  return TableInfo.IndexOfColumn(columnName.Name);
43 
44  return -1;
45  }
46 
47  protected override ObjectName GetResolvedColumnName(int column) {
48  return new ObjectName(TableName, tableInfo[column].ColumnName);
49  }
50 
51  public bool TypeEquals(IRootTable other) {
52  return other == this;
53  }
54  }
55 }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
ReferenceTable(ITable parent, TableInfo tableInfo)
Describes the name of an object within a database.
Definition: ObjectName.cs:44
ReferenceTable(ITable parent, ObjectName tableName)
ObjectName TableName
Gets the fully qualified name of the table that is ensured to be unique within the system...
Definition: TableInfo.cs:97
override ObjectName GetResolvedColumnName(int column)
override int IndexOfColumn(ObjectName columnName)
int IndexOfColumn(string columnName)
Gets the offset of the column with the given name.
Definition: TableInfo.cs:310
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
Definition: ObjectName.cs:99
string Name
Gets the name of the object being referenced.
Definition: ObjectName.cs:108
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
Interface that is implemented by all root tables.
Definition: IRootTable.cs:33