本文整理汇总了C#中SqlType.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SqlType.GetType方法的具体用法?C# SqlType.GetType怎么用?C# SqlType.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlType
的用法示例。
在下文中一共展示了SqlType.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeTo
public static void SerializeTo(BinaryWriter writer, SqlType type)
{
writer.Write((byte) type.TypeCode);
if (type.IsPrimitive) {
if (type is NumericType) {
var numericType = (NumericType) type;
writer.Write(numericType.Size);
writer.Write(numericType.Scale);
} else if (type is StringType) {
var stringType = (StringType) type;
writer.Write(stringType.MaxSize);
if (stringType.Locale != null) {
writer.Write((byte) 1);
writer.Write(stringType.Locale.Name);
} else {
writer.Write((byte) 0);
}
} else if (type is BinaryType) {
var binaryType = (BinaryType) type;
writer.Write(binaryType.MaxSize);
} else if (type is BooleanType ||
type is IntervalType ||
type is DateType ||
type is NullType) {
// nothing to add to the SQL Type Code
} else {
throw new NotSupportedException(String.Format("The data type '{0}' cannot be serialized.", type.GetType().FullName));
}
} else if (type is UserType) {
var userType = (UserType) type;
writer.Write((byte) 1); // The code of custom type
writer.Write(userType.FullName.FullName);
} else if (type is QueryType) {
// nothing to do for the Query Type here
} else if (type is ArrayType) {
var arrayType = (ArrayType) type;
writer.Write(arrayType.Length);
} else {
throw new NotSupportedException();
}
}