本文整理汇总了C#中SqlTypeCode类的典型用法代码示例。如果您正苦于以下问题:C# SqlTypeCode类的具体用法?C# SqlTypeCode怎么用?C# SqlTypeCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlTypeCode类属于命名空间,在下文中一共展示了SqlTypeCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NumericType
public NumericType(SqlTypeCode typeCode, int precision, int scale)
: base("NUMERIC", typeCode)
{
AssertIsNumeric(typeCode);
Precision = precision;
Scale = scale;
}
示例2: GetRuntimeType
public void GetRuntimeType(SqlTypeCode code, Type expectedType)
{
var type = PrimitiveTypes.Interval(code);
var objType = type.GetRuntimeType();
Assert.AreEqual(expectedType, objType);
}
示例3: NumericType
public NumericType(SqlTypeCode sqlType, int size, byte scale)
: base("NUMERIC", sqlType)
{
AssertIsNumeric(sqlType);
Size = size;
Scale = scale;
}
示例4: ColumnAttribute
public ColumnAttribute(string name, SqlTypeCode type, int size, int scale)
{
ColumnName = name;
SqlType = type;
Size = size;
Scale = scale;
}
示例5: GetRuntime
public static void GetRuntime(SqlTypeCode code, Type expectedType)
{
var type = PrimitiveTypes.Numeric(code);
var runtimeType = type.GetRuntimeType();
Assert.AreEqual(expectedType, runtimeType);
}
示例6: ParseString
public void ParseString(string input, SqlTypeCode typeCode)
{
var sqlType = SqlType.Parse(input);
Assert.IsNotNull(sqlType);
Assert.IsInstanceOf<DateType>(sqlType);
Assert.AreEqual(typeCode, sqlType.TypeCode);
}
示例7: ParseString
public void ParseString(string input, SqlTypeCode expected)
{
var type = SqlType.Parse(input);
Assert.IsNotNull(type);
Assert.IsInstanceOf<IntervalType>(type);
Assert.AreEqual(expected, type.TypeCode);
}
示例8: StringType
public StringType(SqlTypeCode typeCode, int maxSize, Encoding encoding, CultureInfo locale)
: base("STRING", typeCode)
{
if (encoding == null)
throw new ArgumentNullException("encoding");
AssertIsString(typeCode);
MaxSize = maxSize;
Locale = locale;
Encoding = encoding;
}
示例9: CastToString
public void CastToString(SqlTypeCode typeCode, bool value, string expected)
{
var type = PrimitiveTypes.Boolean(typeCode);
var boolean = new SqlBoolean(value);
var casted = type.CastTo(boolean, PrimitiveTypes.String());
Assert.IsInstanceOf<SqlString>(casted);
Assert.AreEqual(expected, casted.ToString());
}
示例10: Resolve
public static SqlType Resolve(SqlTypeCode typeCode, string typeName, DataTypeMeta[] metadata, ITypeResolver resolver)
{
if (PrimitiveTypes.IsPrimitive(typeCode))
return PrimitiveTypes.Resolve(typeCode, typeName, metadata);
if (resolver == null)
throw new NotSupportedException(String.Format("Cannot resolve type '{0}' without context.", typeName));
var resolveCcontext = new TypeResolveContext(typeCode, typeName, metadata);
return resolver.ResolveType(resolveCcontext);
}
示例11: ParseString
public static void ParseString(string input, SqlTypeCode expectedTypeCode, int expectedSize)
{
var sqlType = SqlType.Parse(input);
Assert.IsNotNull(sqlType);
Assert.IsInstanceOf<BinaryType>(sqlType);
Assert.AreEqual(expectedTypeCode, sqlType.TypeCode);
var binType = (BinaryType) sqlType;
Assert.AreEqual(expectedSize, binType.MaxSize);
}
示例12: TypeResolveContext
public TypeResolveContext(SqlTypeCode typeCode, string typeName, DataTypeMeta[] meta)
{
TypeCode = typeCode;
TypeName = typeName;
this.meta = new Dictionary<string, DataTypeMeta>(StringComparer.OrdinalIgnoreCase);
if (meta != null) {
foreach (var typeMeta in meta) {
this.meta[typeMeta.Name] = typeMeta;
}
}
}
示例13: CreateFrom
public static void CreateFrom(SqlTypeCode code, int precision, int scale, object value)
{
var type = PrimitiveTypes.Numeric(code, precision, scale);
var result = type.CreateFrom(value);
Assert.IsNotNull(result);
Assert.IsFalse(result.IsNull);
Assert.IsInstanceOf<SqlNumber>(result);
var number = (SqlNumber) result;
Assert.AreEqual(scale, number.Scale);
Assert.AreEqual(precision, number.Precision);
}
示例14: Boolean
public static BooleanType Boolean(SqlTypeCode sqlType)
{
return new BooleanType(sqlType);
}
示例15: DateTime
public static DateType DateTime(SqlTypeCode sqlType)
{
return new DateType(sqlType);
}