本文整理汇总了C#中DataValue.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# DataValue.IsNull方法的具体用法?C# DataValue.IsNull怎么用?C# DataValue.IsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataValue
的用法示例。
在下文中一共展示了DataValue.IsNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetClrValue
/// <summary>
/// Gets the CLR value.
/// </summary>
/// <param name="val">The val.</param>
/// <returns></returns>
public static object GetClrValue(DataValue val)
{
if (val == null || val.IsNull())
return null;
switch (val.DataType)
{
case DataType.DataType_BLOB:
return ((BLOBValue)val).Data;
case DataType.DataType_Boolean:
return ((BooleanValue)val).Boolean;
case DataType.DataType_Byte:
return ((ByteValue)val).Byte;
case DataType.DataType_CLOB:
return ((CLOBValue)val).Data;
case DataType.DataType_DateTime:
return ((DateTimeValue)val).DateTime;
case DataType.DataType_Decimal:
return ((DecimalValue)val).Decimal;
case DataType.DataType_Double:
return ((DoubleValue)val).Double;
case DataType.DataType_Int16:
return ((Int16Value)val).Int16;
case DataType.DataType_Int32:
return ((Int32Value)val).Int32;
case DataType.DataType_Int64:
return ((Int64Value)val).Int64;
case DataType.DataType_Single:
return ((SingleValue)val).Single;
case DataType.DataType_String:
return ((StringValue)val).String;
default:
return null;
}
}
示例2: ConvertDataValue
/// <summary>
/// Converts a source DataValue to a DataValue of the given type
/// </summary>
/// <param name="src">The source data value</param>
/// <param name="dataType">The data type to convert to</param>
/// <param name="nullIfIncompatible">Determines what happens if the source and destination types are incompatible</param>
/// <param name="truncate">Determines what happens if the value is outside the valid range for the destination type (e.g. convert 1000000 from FdoInt32Value to FdoInt16Value). Applicable only when both source and destination types are one of Boolean, Byte, Decimal, Double, Int16, Int32, Int64 or Single</param>
/// <returns>The converted data value</returns>
public static DataValue ConvertDataValue(DataValue src, DataType dataType, bool nullIfIncompatible, bool truncate)
{
//Calling code should not be passing in null data value in the first place
if (src == null || src.IsNull())
throw new ArgumentNullException("src");
if (src.DataType == dataType)
return src;
//Get this out of the way, throw if source cannot be converted to target and not
//using null coercion.
if (!nullIfIncompatible && !IsConvertible(src.DataType, dataType))
throw new FdoException("Unable to convert source data type <" + src.DataType + "> to <" + dataType + ">");
//assert nullIfIncompatible == true
switch (src.DataType)
{
case DataType.DataType_BLOB:
{
return null;
}
case DataType.DataType_Boolean:
{
return ConvertBoolean((BooleanValue)src, dataType);
}
case DataType.DataType_Byte:
{
return ConvertByte((ByteValue)src, dataType);
}
case DataType.DataType_CLOB:
{
return null;
}
case DataType.DataType_DateTime:
{
return ConvertDateTime((DateTimeValue)src, dataType);
}
case DataType.DataType_Decimal:
{
return ConvertDecimal((DecimalValue)src, dataType, truncate);
}
case DataType.DataType_Double:
{
return ConvertDouble((DoubleValue)src, dataType, truncate);
}
case DataType.DataType_Int16:
{
return ConvertInt16((Int16Value)src, dataType, truncate);
}
case DataType.DataType_Int32:
{
return ConvertInt32((Int32Value)src, dataType, truncate);
}
case DataType.DataType_Int64:
{
return ConvertInt64((Int64Value)src, dataType, truncate);
}
case DataType.DataType_Single:
{
return ConvertSingle((SingleValue)src, dataType, truncate);
}
case DataType.DataType_String:
{
return ConvertString((StringValue)src, dataType, truncate);
}
}
return null;
}