32 UniqueName = uniqueKey;
33 QueryExpression = queryExpression;
36 IgnoreCase = caseInsensitive;
40 if (schema == null && table == null)
43 if (AliasName != null) {
44 string ts = AliasName.Parent.Name;
45 string tt = AliasName.Name;
47 return StringCompare(tt, table);
48 if (StringCompare(tt, table) && StringCompare(ts, schema))
62 public bool IgnoreCase {
get;
private set; }
64 public string UniqueName {
get;
private set; }
77 if (columnNames == null) {
78 columnNames = QueryFrom.GetResolvedColumns();
81 if (AliasName != null) {
82 for (
int i = 0; i < columnNames.Length; ++i) {
83 columnNames[i] =
new ObjectName(AliasName, columnNames[i].Name);
90 var comparison = IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
91 return String.Equals(str1, str2, comparison);
94 private bool Matches(
ObjectName name,
string catalog,
string schema,
string table,
string column) {
95 var tableName = name.
Parent;
96 var schemaName = tableName == null ? null : tableName.
Parent;
97 var catalogName = schemaName == null ? null : schemaName.
Parent;
98 var columnName = name.
Name;
102 if (!StringCompare(columnName, column))
107 if (tableName == null)
110 string tname = tableName.Name;
111 if (tname != null && !StringCompare(tname, table))
117 string sname = schemaName != null ? schemaName.Name : null;
118 if (sname != null && !StringCompare(sname, schema))
121 string cname = catalogName != null ? catalogName.Name : null;
122 if (cname != null && !StringCompare(cname, catalog))
131 if (String.IsNullOrEmpty(catalog) &&
132 String.IsNullOrEmpty(schema) &&
133 String.IsNullOrEmpty(table) &&
134 String.IsNullOrEmpty(column))
135 return columnNames.Length;
137 return columnNames.Count(v => Matches(v, catalog, schema, table, column));
144 var result = columnNames.FirstOrDefault(v => Matches(v, catalog, schema, table, column));
146 throw new InvalidOperationException(
"Couldn't resolve to a column.");
An implementation of IFromTableSource that wraps around a SqlQueryExpression as a sub-query source...
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.
void EnsureColumnNames()
Makes sure the columnNames list is created correctly.
bool Matches(ObjectName name, string catalog, string schema, string table, string column)
FromTableSubQuerySource(bool caseInsensitive, string uniqueKey, SqlQueryExpression queryExpression, QueryExpressionFrom fromSet, ObjectName alias)
ObjectName ResolveColumn(string catalog, string schema, string table, string column)
Resolves a variable within the current source.
bool StringCompare(string str1, string str2)
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 ...
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
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.