18 using System.Collections.Generic;
22 namespace Deveel.Data.Sql.Tables {
31 this.aliases = aliases;
32 this.columnMap = columnMap;
34 SetColumnMap(columnMap);
38 reverseColumnMap =
new int[Parent.ColumnCount()];
39 for (
int i = 0; i < reverseColumnMap.Length; ++i) {
40 reverseColumnMap[i] = -1;
43 var parentInfo = Parent.TableInfo;
44 subsetTableInfo =
new TableInfo(parentInfo.TableName);
46 for (
int i = 0; i < mapping.Length; ++i) {
47 int mapTo = mapping[i];
49 var origColumnInfo = Parent.TableInfo[mapTo];
50 var columnInfo =
new ColumnInfo(aliases[i].Name, origColumnInfo.ColumnType) {
52 IsNotNull = origColumnInfo.IsNotNull,
53 IndexType = origColumnInfo.IndexType
58 reverseColumnMap[mapTo] = i;
61 subsetTableInfo = subsetTableInfo.
AsReadOnly();
64 protected override int ColumnCount {
65 get {
return aliases.Length; }
69 get {
return subsetTableInfo; }
73 for (
int i = 0; i < aliases.Length; ++i) {
74 if (columnName.
Equals(aliases[i])) {
82 return aliases[column];
90 int mappedOriginalColumn = originalColumn;
92 mappedOriginalColumn = columnMap[originalColumn];
95 return base.GetIndex(columnMap[column], mappedOriginalColumn, table);
98 protected override IEnumerable<int>
ResolveRows(
int column, IEnumerable<int> rowSet,
ITable ancestor) {
99 return base.ResolveRows(columnMap[column], rowSet, ancestor);
103 return Parent.GetValue(rowNumber, columnMap[columnOffset]);
107 return this == other;
Defines the metadata properties of a column within a table of a database.
readonly ObjectName[] aliases
override int IndexOfColumn(ObjectName columnName)
Defines the contract to access the data contained into a table of a database.
override ColumnIndex GetIndex(int column, int originalColumn, ITable table)
SubsetColumnTable(ITable parent, int[] columnMap, ObjectName[] aliases)
void AddColumnSafe(ColumnInfo column)
Describes the name of an object within a database.
override bool Equals(object obj)
TableInfo subsetTableInfo
TableInfo AsReadOnly()
Creates a new instance of TableInfo as an immutable copy of this table metadata.
bool TypeEquals(IRootTable other)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
void SetColumnMap(int[] mapping)
override IEnumerable< int > ResolveRows(int column, IEnumerable< int > rowSet, ITable ancestor)
SqlExpression DefaultExpression
Gets or sets a SqlExpression used as a DEFAULT when a constraint for the column is to SET DEFAULT...
override DataObject GetValue(long rowNumber, int columnOffset)
Gets a single cell within the table that is located at the given column offset and row...
Defines the metadata properties of a table existing within a database.
Interface that is implemented by all root tables.
override ObjectName GetResolvedColumnName(int column)