本文整理汇总了C#中Field.CastTo方法的典型用法代码示例。如果您正苦于以下问题:C# Field.CastTo方法的具体用法?C# Field.CastTo怎么用?C# Field.CastTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field.CastTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
public static Field ToString(Field value)
{
return value.CastTo(PrimitiveTypes.String());
}
示例2: ToTimeStamp
public static Field ToTimeStamp(Field obj, Field timeZone)
{
var result = obj.CastTo(PrimitiveTypes.TimeStamp());
if (!Field.IsNullField(timeZone)) {
var tz = timeZone.Value.ToString();
var timeStamp = ((SqlDateTime) result.Value).AtTimeZone(tz);
result = Field.TimeStamp(timeStamp);
}
return result;
}
示例3: ToNumber
public static Field ToNumber(Field value)
{
return value.CastTo(PrimitiveTypes.Numeric());
}
示例4: ToDateTime
public static Field ToDateTime(Field obj)
{
return obj.CastTo(PrimitiveTypes.DateTime());
}
示例5: ToBinary
public static Field ToBinary(Field value)
{
return value.CastTo(PrimitiveTypes.Binary());
}
示例6: Cast
public static Field Cast(IRequest context, Field value, SqlType destType)
{
var type = destType.Resolve(context);
return value.CastTo(type);
}
示例7: SetOutput
public void SetOutput(string argName, Field value)
{
var parameter = GetParameter(argName);
if (parameter == null)
throw new InvalidOperationException(String.Format("Routine {0} has none parameter named '{1}'.", Routine.RoutineInfo.RoutineName, argName));
if (!parameter.IsOutput)
throw new InvalidOperationException(String.Format("The parameter '{0}' is not OUTPUT", argName));
if (!parameter.IsNullable &&
value.IsNull)
throw new ArgumentException(String.Format("The output parameter '{0}' is marked as NOT NULL but a NULL value was passed.", argName));
if (!parameter.Type.Equals(value.Type)) {
if (!parameter.Type.IsComparable(value.Type))
throw new ArgumentException(
String.Format("The passed value of type '{0}' is not assignable to the type '{1}' of parameter '{2}'.", value.Type,
parameter.Type, parameter.Name));
value = value.CastTo(parameter.Type);
}
if (output == null)
output = new Dictionary<string, Field>();
output[argName] = value;
}