//Gets a list of strings of the columns that exists in the table on the database with tableName private static List <DatabaseColumnInfo> GetColumnInformation(this IDbConnection db, string tableName, ISqlProvider sqlProvider) { var columns = new List <DatabaseColumnInfo>(); using (IDbCommand cmd = db.CreateCommand()) { //create sql that gets table information cmd.CommandText = sqlProvider.TableInformation + " " + db.GetDialectProvider().GetQuotedName(tableName); IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var tempColumn = new DatabaseColumnInfo { Name = reader[sqlProvider.ColumnName].ToString(), SqlType = reader[sqlProvider.ColumnType].ToString(), Nullable = reader[sqlProvider.Nullable].ToString() == sqlProvider.NotNullValue ? false : true, Extra = reader[sqlProvider.Extra].ToString() }; columns.Add(tempColumn); } reader.Close(); } return(columns); }
public override DatabaseColumnInfo ODAColumnToOrigin(string Name, string ColumnType, int Length, int Scale) { DatabaseColumnInfo ColInof = new DatabaseColumnInfo(); ColInof.Name = Name; ColInof.NoLength = false; ColInof.Length = Length; ColInof.Scale = Scale; if (ColumnType.Trim() == ODAdbType.OBinary.ToString()) { ColInof.ColumnType = "BLOB"; ColInof.NoLength = true; } else if (ColumnType.Trim() == ODAdbType.ODatetime.ToString()) { ColInof.ColumnType = "DATETIME"; ColInof.NoLength = true; } else if (ColumnType.Trim() == ODAdbType.ODecimal.ToString()) { ColInof.ColumnType = "DECIMAL"; ColInof.NoLength = false; ColInof.Length = 31; ColInof.Scale = 12; } else if (ColumnType.Trim() == ODAdbType.OInt.ToString()) { ColInof.ColumnType = "INT"; ColInof.NoLength = true; } else if (ColumnType.Trim() == ODAdbType.OChar.ToString()) { ColInof.ColumnType = "CHAR"; ColInof.Scale = 0; } else if (ColumnType.Trim() == ODAdbType.OVarchar.ToString()) { ColInof.ColumnType = "VARCHAR"; ColInof.Scale = 0; } else { ColInof.ColumnType = "VARCHAR"; ColInof.Scale = 0; } return(ColInof); }