43 this.UniqueName = uniqueName;
45 RootTableName = rootName;
46 if (givenName != null) {
47 GivenTableName = givenName;
49 GivenTableName = rootName;
52 IgnoreCase = caseInsensitive;
53 this.tableQuery = tableQuery;
56 public bool IgnoreCase {
get;
private set; }
63 get {
return tableQuery.QueryPlanNode; }
66 public string UniqueName {
get;
private set; }
70 int colCount = tableInfo.ColumnCount;
72 for (
int i = 0; i < colCount; ++i) {
73 vars[i] =
new ObjectName(GivenTableName, tableInfo[i].ColumnName);
80 var comparison = IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
81 return String.Equals(str1, str2, comparison);
86 var schemaName = GivenTableName.Parent;
87 var catalogName = schemaName == null ? null : schemaName.Parent;
90 var givenSchema = schemaName != null ? schemaName.Name : null;
91 if (schema != null && !StringCompare(schema, givenSchema)) {
96 var givenCatalog = catalogName != null ? catalogName.Name : null;
97 if (catalog != null && !StringCompare(catalog, givenCatalog))
100 if (table != null && !StringCompare(table, GivenTableName.Name)) {
114 var schemaName = GivenTableName.Parent;
115 var catalogName = schemaName == null ? null : schemaName.Parent;
117 var givenCatalog = catalogName != null ? catalogName.Name : null;
118 if (catalog != null && !StringCompare(catalog, givenCatalog))
121 var givenSchema = schemaName != null ? schemaName.Name : null;
122 if (schema != null && !StringCompare(schema, givenSchema))
125 if (table != null && !StringCompare(table, GivenTableName.Name)) {
129 if (column != null) {
133 int i = tableInfo.IndexOfColumn(column);
135 return i == -1 ? 0 : 1;
138 return tableInfo.Count(columnInfo => StringCompare(columnInfo.ColumnName, column));
142 return tableInfo.ColumnCount;
146 var schemaName = GivenTableName.
Parent;
147 var catalogName = schemaName == null ? null : schemaName.
Parent;
149 var givenCatalog = catalogName != null ? catalogName.
Name : null;
150 if (catalog != null && !StringCompare(catalog, givenCatalog))
151 throw new InvalidOperationException(
"Incorrect catalog.");
154 var givenSchema = GivenTableName.Parent != null ? GivenTableName.Parent.Name : null;
155 if (schema != null && !StringCompare(schema, givenSchema))
157 throw new InvalidOperationException(
"Incorrect schema.");
159 if (table != null && !StringCompare(table, GivenTableName.Name))
161 throw new InvalidOperationException(
"Incorrect table.");
163 if (column != null) {
166 int i = tableInfo.IndexOfColumn(column);
168 throw new InvalidOperationException(
"Could not resolve '" + column +
"'");
170 return new ObjectName(GivenTableName, column);
175 tableInfo.Where(x => StringCompare(x.ColumnName, column))
176 .Select(x => x.ColumnName)
179 if (String.IsNullOrEmpty(columnName))
180 throw new InvalidOperationException(String.Format(
"Could not resolve column '{0}' within the table '{1}'.", column,
183 return new ObjectName(GivenTableName, columnName);
187 return new ObjectName(GivenTableName, tableInfo[0].ColumnName);
bool StringCompare(string str1, string str2)
A query to the database to select data from a set of tables and columns.
A single table resource item in a query which handles the behaviour of resolving references to column...
Describes the name of an object within a database.
ObjectName ResolveColumn(string catalog, string schema, string table, string column)
Resolves a variable within the current source.
FromTableDirectSource(bool caseInsensitive, ITableQueryInfo tableQuery, string uniqueName, ObjectName givenName, ObjectName rootName)
Constructs the source.
A node element of a query plan tree. /summary>
readonly TableInfo tableInfo
TableInfo TableInfo
Gets a read-only TableInfo that describes the columns in this table source, and the name of the table...
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
readonly ITableQueryInfo tableQuery
string Name
Gets the name of the object being referenced.
bool MatchesReference(string catalog, string schema, string table)
Checks if the table matches the given catalog, schema and table.
int ResolveColumnCount(string catalog, string schema, string table, string column)
Returns the number of instances we can resolve the given catalog, schema, table and column name to a ...
Defines the metadata properties of a table existing within a database.
An implementation of IFromTableSource that wraps around a ObjectName/ITable object.