Example #1
0
        private void ParseColumnInfo(DataRow row)
        {
            ColumnName   = row["COLUMN_NAME"].ToString();
            AllowNull    = row["IS_NULLABLE"] != DBNull.Value && row["IS_NULLABLE"].ToString() == "YES";
            Comment      = row["COLUMN_COMMENT"].ToString();
            Collation    = row["COLLATION_NAME"].ToString();
            CharacterSet = row["CHARACTER_SET_NAME"].ToString();
            DefaultValue = row["COLUMN_DEFAULT"].ToString();

            string columnType = row["COLUMN_TYPE"].ToString().ToLowerInvariant();
            int    index      = columnType.IndexOf(' ');

            if (index == -1)
            {
                index = columnType.Length;
            }
            DataType = columnType.Substring(0, index);
            CleanDataType();

            columnType = columnType.Substring(index);
            IsUnsigned = columnType.IndexOf("unsigned") != -1;
            IsZerofill = columnType.IndexOf("zerofill") != -1;

            PrimaryKey = row["COLUMN_KEY"].ToString() == "PRI";
            Precision  = DataRowHelpers.GetValueAsInt32(row, "NUMERIC_PRECISION");
            Scale      = DataRowHelpers.GetValueAsInt32(row, "NUMERIC_SCALE");

            string extra = row["EXTRA"].ToString().ToLowerInvariant();

            if (extra != null)
            {
                AutoIncrement = extra.IndexOf("auto_increment") != -1;
            }
        }
Example #2
0
        private void ParseTableData(DataRow tableRow)
        {
            Schema       = tableRow["TABLE_SCHEMA"].ToString();
            Name         = tableRow["TABLE_NAME"].ToString();
            Engine       = tableRow["ENGINE"].ToString();
            RowFormat    = (RowFormat)Enum.Parse(typeof(RowFormat), tableRow["ROW_FORMAT"].ToString());
            AvgRowLength = DataRowHelpers.GetValueAsUInt64(tableRow, "AVG_ROW_LENGTH");
            AutoInc      = DataRowHelpers.GetValueAsUInt64(tableRow, "AUTO_INCREMENT");
            Comment      = tableRow["TABLE_COMMENT"].ToString();
            Collation    = tableRow["TABLE_COLLATION"].ToString();
            if (Collation != null)
            {
                int index = Collation.IndexOf("_");
                if (index != -1)
                {
                    CharacterSet = Collation.Substring(0, index);
                }
            }

            string createOpt = (string)tableRow["CREATE_OPTIONS"];

            if (string.IsNullOrEmpty(createOpt))
            {
                ParseCreateOptions(createOpt.ToLowerInvariant());
            }
        }