public override DataTypeInfo Execute() { RelationalRow row = null; command.Connection.Open(); var rdr = ExecuteReader(command); if (rdr.Read()) { row = new RelationalRow(); row.IsNullable = rdr.GetString(0); row.DataType = rdr.GetString(1); row.CharacterMaximumLength = rdr.IsDBNull(2) ? 0 : rdr.GetInt32(2); row.NumericPrecision = rdr.IsDBNull(3) ? 0 : rdr.GetByte(3); row.NumericScale = rdr.IsDBNull(4) ? 0 : rdr.GetInt32(4); row.DateTimePrecision = rdr.IsDBNull(5) ? 0 : rdr.GetInt16(5); row.CharacterSetName = rdr.IsDBNull(6) ? string.Empty : rdr.GetString(6); row.CollationName = rdr.IsDBNull(7) ? string.Empty : rdr.GetString(7); row.DomainName = rdr.IsDBNull(8) ? string.Empty : rdr.GetString(8); } command.Connection.Close(); if (row != null) { var factory = new DataTypeInfoFactory(); var dataTypeInfo = factory.Instantiate(row); return dataTypeInfo; } else return null; }
public override DataTypeInfo Execute() { RelationalRow row = null; command.Connection.Open(); var rdr = ExecuteReader(command); if (rdr.Read()) { row = new RelationalRow(); row.IsNullable = rdr.GetString(0); row.DataType = rdr.GetString(1); row.CharacterMaximumLength = rdr.IsDBNull(2) ? 0 : rdr.GetInt32(2); row.NumericPrecision = rdr.IsDBNull(3) ? 0 : rdr.GetByte(3); row.NumericScale = rdr.IsDBNull(4) ? 0 : rdr.GetInt32(4); row.DateTimePrecision = rdr.IsDBNull(5) ? 0 : rdr.GetInt16(5); row.CharacterSetName = rdr.IsDBNull(6) ? string.Empty : rdr.GetString(6); row.CollationName = rdr.IsDBNull(7) ? string.Empty : rdr.GetString(7); row.DomainName = rdr.IsDBNull(8) ? string.Empty : rdr.GetString(8); } command.Connection.Close(); if (row != null) { var factory = new DataTypeInfoFactory(); var dataTypeInfo = factory.Instantiate(row); return(dataTypeInfo); } else { return(null); } }
public DataTypeInfo Instantiate(RelationalRow row) { DataTypeInfo dataTypeInfo = null; if (row.CharacterMaximumLength > 0) { dataTypeInfo = new TextInfo(); ((TextInfo)dataTypeInfo).Length = row.CharacterMaximumLength; ((TextInfo)dataTypeInfo).CharSet = row.CharacterSetName; ((TextInfo)dataTypeInfo).Collation = row.CollationName; ((TextInfo)dataTypeInfo).Domain = row.DomainName; } else if (row.NumericScale > 0) { dataTypeInfo = new NumericInfo(); ((NumericInfo)dataTypeInfo).Scale = row.NumericScale; ((NumericInfo)dataTypeInfo).Precision = row.NumericPrecision; } else if (row.DateTimePrecision > 0) { dataTypeInfo = new DateTimeInfo(); ((DateTimeInfo)dataTypeInfo).Precision = row.DateTimePrecision; } else { dataTypeInfo = new DataTypeInfo(); } dataTypeInfo.Name = row.DataType.ToLower(); dataTypeInfo.Nullable = row.IsNullable.ToUpper() == "YES".ToUpper(); return dataTypeInfo; }