/// <summary> /// /// </summary> /// <param name="tableDef"></param> private void AddIndexesToTableDef(TableDefHelper tableDef) { DataTable dbIndexes = _connection.GetSchema("Indexes"); foreach (DataRow r in dbIndexes.Select("TABLE_NAME = '" + tableDef.TableName + "'")) { DataColumn newCol = new DataColumn(); newCol.ColumnName = r["COLUMN_NAME"].ToString(); newCol.AllowDBNull = r["NULLS"].ToString() == "1"; newCol.DataType = DbTypesConverter.ProviderTypeToType(r["TYPE"].ToString()); } }
/// <summary> /// /// </summary> /// <param name="tableDef"></param> private void AddColumnsToTableDef(TableDefHelper tableDef) { DataTable dbColumns = _connection.GetSchema("Columns"); foreach (DataRow r in dbColumns.Select("TABLE_NAME = '" + tableDef.TableName + "'")) { /*System.Diagnostics.Debug.WriteLine("-------------"); * foreach (DataColumn c in r.Table.Columns) * { * System.Diagnostics.Debug.WriteLine("\t" + c.ColumnName + " " + r[c.ColumnName]); * }*/ DataColumn field = new DataColumn(); field.ColumnName = r["COLUMN_NAME"].ToString(); field.DataType = DbTypesConverter.ProviderTypeToType(r["DATA_TYPE"].ToString()); if (r["DATA_TYPE"].ToString() == "130") // strings { field.MaxLength = int.Parse(r["CHARACTER_MAXIMUM_LENGTH"].ToString()); } tableDef.Columns.Add(field); } }