/// <summary> /// Constructor /// </summary> public DbTypeTypeConverter() { ConvertToTypes.Add(typeof(Type), DbTypeToType); ConvertToTypes.Add(typeof(SqlDbType), DbTypeToSqlDbType); ConvertFromTypes.Add(typeof(Type).GetType(), TypeToDbType); ConvertFromTypes.Add(typeof(SqlDbType), SqlDbTypeToDbType); }
/// <summary> /// Constructor /// </summary> public SqlDbTypeTypeConverter() : base() { ConvertToTypes.Add(typeof(Type), SqlDbTypeToType); ConvertToTypes.Add(typeof(DbType), SqlDbTypeToDbType); ConvertFromTypes.Add(typeof(Type).GetType(), TypeToSqlDbType); ConvertFromTypes.Add(typeof(DbType), DbTypeToSqlDbType); Conversions = new ConcurrentDictionary <Type, DbType>(); Conversions.AddOrUpdate(typeof(byte), DbType.Byte, (x, y) => y); Conversions.AddOrUpdate(typeof(byte?), DbType.Byte, (x, y) => y); Conversions.AddOrUpdate(typeof(sbyte), DbType.SByte, (x, y) => y); Conversions.AddOrUpdate(typeof(sbyte?), DbType.SByte, (x, y) => y); Conversions.AddOrUpdate(typeof(short), DbType.Int16, (x, y) => y); Conversions.AddOrUpdate(typeof(short?), DbType.Int16, (x, y) => y); Conversions.AddOrUpdate(typeof(ushort), DbType.UInt16, (x, y) => y); Conversions.AddOrUpdate(typeof(ushort?), DbType.UInt16, (x, y) => y); Conversions.AddOrUpdate(typeof(int), DbType.Int32, (x, y) => y); Conversions.AddOrUpdate(typeof(int?), DbType.Int32, (x, y) => y); Conversions.AddOrUpdate(typeof(uint), DbType.UInt32, (x, y) => y); Conversions.AddOrUpdate(typeof(uint?), DbType.UInt32, (x, y) => y); Conversions.AddOrUpdate(typeof(long), DbType.Int64, (x, y) => y); Conversions.AddOrUpdate(typeof(long?), DbType.Int64, (x, y) => y); Conversions.AddOrUpdate(typeof(ulong), DbType.UInt64, (x, y) => y); Conversions.AddOrUpdate(typeof(ulong?), DbType.UInt64, (x, y) => y); Conversions.AddOrUpdate(typeof(float), DbType.Single, (x, y) => y); Conversions.AddOrUpdate(typeof(float?), DbType.Single, (x, y) => y); Conversions.AddOrUpdate(typeof(double), DbType.Double, (x, y) => y); Conversions.AddOrUpdate(typeof(double?), DbType.Double, (x, y) => y); Conversions.AddOrUpdate(typeof(decimal), DbType.Decimal, (x, y) => y); Conversions.AddOrUpdate(typeof(decimal?), DbType.Decimal, (x, y) => y); Conversions.AddOrUpdate(typeof(bool), DbType.Boolean, (x, y) => y); Conversions.AddOrUpdate(typeof(bool?), DbType.Boolean, (x, y) => y); Conversions.AddOrUpdate(typeof(string), DbType.String, (x, y) => y); Conversions.AddOrUpdate(typeof(char), DbType.StringFixedLength, (x, y) => y); Conversions.AddOrUpdate(typeof(char?), DbType.StringFixedLength, (x, y) => y); Conversions.AddOrUpdate(typeof(Guid), DbType.Guid, (x, y) => y); Conversions.AddOrUpdate(typeof(Guid?), DbType.Guid, (x, y) => y); Conversions.AddOrUpdate(typeof(DateTime), DbType.DateTime2, (x, y) => y); Conversions.AddOrUpdate(typeof(DateTime?), DbType.DateTime2, (x, y) => y); Conversions.AddOrUpdate(typeof(DateTimeOffset), DbType.DateTimeOffset, (x, y) => y); Conversions.AddOrUpdate(typeof(DateTimeOffset?), DbType.DateTimeOffset, (x, y) => y); Conversions.AddOrUpdate(typeof(byte[]), DbType.Binary, (x, y) => y); }