protected override void PopulateColumns(IList <Column> columnsCollection) { using (Database.CreateConnectionScope()) { var primaryKeys = new HashSet <string>(); if (!IsReadOnly) { using (var command = Connection.CreateCommand()) { command.CommandText = "select " + " TRIM(sg.rdb$field_name) as field_name "+ "from " + " rdb$indices ix "+ " left join rdb$index_segments sg on ix.rdb$index_name = sg.rdb$index_name "+ " left join rdb$relation_constraints rc on rc.rdb$index_name = ix.rdb$index_name "+ "where " + " rc.rdb$constraint_type = 'PRIMARY KEY' "+ " and rc.rdb$relation_name = @TableName"; command.Parameters.AddWithValue("@TableName", Name.ToUpper()); using (var reader = command.ExecuteReader()) { while (reader.Read()) { primaryKeys.Add(reader.GetString(0)); } } } } using (var columns = database.Connection.GetSchema("Columns", new[] { null, TableSchema, TableName, null })) { foreach (DataRow row in columns.Rows) { var column = new Column(this) { Name = row["COLUMN_NAME"].ToString(), ProviderType = row["COLUMN_DATA_TYPE"].ToString().ToLower(), }; column.Type = FbProvider.MapType(column.ProviderType); if (column.Type == typeof(string)) { column.ProviderType += "(" + row["COLUMN_SIZE"] + ")"; } column.InPrimaryKey = primaryKeys.Contains(column.Name); columnsCollection.Add(column); } } } }
protected override void PopulateParameters(IList <Parameter> parametersCollection) { using (var parameters = database.Connection.GetSchema("ProcedureParameters", new[] { null, null, Name })) { foreach (DataRow row in parameters.Rows) { var p = new Parameter() { Name = (string)row["PARAMETER_NAME"], IsOutput = (int)row["PARAMETER_DIRECTION"] == 2, ProviderType = (string)row["PARAMETER_DATA_TYPE"], }; p.ParameterType = FbProvider.MapType(p.ProviderType); if (p.ParameterType == typeof(string)) { p.ProviderType += "(" + row["PARAMETER_SIZE"].ToString() + ")"; } parametersCollection.Add(p); } } }