Deveel.Data.Sql.Query.FromTableDirectSource.ResolveColumnCount C# (CSharp) Method

ResolveColumnCount() public method

public ResolveColumnCount ( string catalog, string schema, string table, string column ) : int
catalog string
schema string
table string
column string
return int
        public int ResolveColumnCount(string catalog, string schema, string table, string column)
        {
            // NOTE: With this type, we can only ever return either 1 or 0 because
            //   it's impossible to have an ambiguous reference

            var schemaName = GivenTableName.Parent;
            var catalogName = schemaName == null ? null : schemaName.Parent;

            var givenCatalog = catalogName != null ? catalogName.Name : null;
            if (catalog != null && !StringCompare(catalog, givenCatalog))
                return 0;

            var givenSchema = schemaName != null ? schemaName.Name : null;
            if (schema != null && !StringCompare(schema, givenSchema))
                return 0;

            if (table != null && !StringCompare(table, GivenTableName.Name)) {
                return 0;
            }

            if (column != null) {
                // TODO: the case-insensitive search in TableInfo
                if (!IgnoreCase) {
                    // Can we resolve the column in this table?
                    int i = tableInfo.IndexOfColumn(column);
                    // If i doesn't equal -1 then we've found our column
                    return i == -1 ? 0 : 1;
                }

                return tableInfo.Count(columnInfo => StringCompare(columnInfo.ColumnName, column));
            }

            // Return the column count
            return tableInfo.ColumnCount;
        }