private List <Parameter> GetProcedureResultSchema(DataTable schema) { List <Parameter> parameters = new List <Parameter>(); foreach (DataRow row1 in schema.Rows) { Type type1 = (Type)row1["DataType"]; int num1 = -1; if (type1 == typeof(string)) { num1 = (int)row1["ColumnSize"]; } SqlServerParameter parameter = new SqlServerParameter(); parameter.DBName = SqlServerTranslatorHelper.GetQualifiedName((string)row1["ColumnName"]); parameter.Direction = ParameterDirection.ReturnValue; SqlServerDbDataType dbDataType = new SqlServerDbDataType(); dbDataType.Size = num1; dbDataType.ProviderType = SqlServerDataTypeConverter.SqlDbType2DatabaseType(row1["ProviderType"]); dbDataType.Type = type1; parameter.DbDataType = dbDataType; parameters.Add(parameter); } return(parameters); }
public static SqlServerView SqlServerViewCollectionToView(DataRow sqlServerView, DataTable sqlServerColumnsColletions) { SqlServerView view = new SqlServerView(); view.Name = sqlServerView["table_name"].ToString(); view.Schema = sqlServerView["table_schema"].ToString(); foreach (DataRow row in sqlServerColumnsColletions.Rows) { SqlServerColumn column = new SqlServerColumn(); SqlServerDbDataType dbDataType = new SqlServerDbDataType(); column.Name = row["ColumnName"].ToString(); column.IsNullable = (bool)row["AllowDBNull"]; dbDataType.ProviderType = SqlServerDataTypeConverter.SqlDbType2DatabaseType(row["ProviderType"]); dbDataType.Type = (Type)row["DataType"]; dbDataType.Size = (int)row["ColumnSize"]; dbDataType.Precision = (Int16)row["NumericPrecision"]; dbDataType.Scale = (Int16)row["NumericScale"]; column.DbDataType = dbDataType; view.Columns.Add(column); } return(view); }
public static SqlServerTable SqlServerTableCollectionToTable(DataRow sqlServerTable, DataTable sqlServerColumnsColletions, DataTable sqlServerForeignKeysCollection) { SqlServerTable table = new SqlServerTable(); table.Name = sqlServerTable["table_name"].ToString(); table.Schema = sqlServerTable["table_schema"].ToString(); DataRow[] rows = sqlServerColumnsColletions.Select("", "ColumnName ASC"); foreach (DataRow row in rows) { SqlServerColumn column = new SqlServerColumn(); SqlServerDbDataType dbDataType = new SqlServerDbDataType(); column.Name = row["ColumnName"].ToString(); column.IsPrimaryKey = (bool)row["IsKey"]; column.IsNullable = (bool)row["AllowDBNull"]; column.IsUnique = (bool)row["IsUnique"]; column.IsIdentity = (bool)row["IsIdentity"]; column.IsReadOnly = (bool)row["IsReadOnly"]; dbDataType.ProviderType = SqlServerDataTypeConverter.SqlDbType2DatabaseType(row["ProviderType"]); dbDataType.Type = (Type)row["DataType"]; dbDataType.Size = (int)row["ColumnSize"]; dbDataType.Precision = (Int16)row["NumericPrecision"]; dbDataType.Scale = (Int16)row["NumericScale"]; column.DbDataType = dbDataType; table.Columns.Add(column); } foreach (DataRow row in sqlServerForeignKeysCollection.Rows) { string columnName = row["ColumnName"].ToString(); table.Columns.Find( delegate(Column column) { return(column.Name.Equals(columnName)); }).IsForeignKey = true; } return(table); }