System.Data.Common.SqlConvert.ConvertToSqlInt64 C# (CSharp) Method

ConvertToSqlInt64() public static method

public static ConvertToSqlInt64 ( object value ) : SqlInt64
value object
return System.Data.SqlTypes.SqlInt64
        public static SqlInt64 ConvertToSqlInt64(object value)
        {
            Debug.Assert(value != null, "null argument in ConvertToSqlInt64");
            if (value == DBNull.Value)
            {
                return SqlInt32.Null;
            }
            Type valueType = value.GetType();
            StorageType stype = DataStorage.GetStorageType(valueType);
            switch (stype)
            {
                case StorageType.SqlInt64:
                    return (SqlInt64)value;
                case StorageType.Int64:
                    return (long)value;
                case StorageType.SqlInt16:
                    return (SqlInt16)value;
                case StorageType.Int16:
                    return (short)value;
                case StorageType.UInt16:
                    return (ushort)value;
                case StorageType.SqlInt32:
                    return (SqlInt32)value;
                case StorageType.Int32:
                    return (int)value;
                case StorageType.UInt32:
                    return (uint)value;
                case StorageType.SqlByte:
                    return (SqlByte)value;
                case StorageType.Byte:
                    return (byte)value;
                default:
                    throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt64));
            }
        }

Usage Example

Esempio n. 1
0
 public override object ConvertValue(object?value)
 {
     if (null != value)
     {
         return(SqlConvert.ConvertToSqlInt64(value));
     }
     return(_nullValue);
 }
All Usage Examples Of System.Data.Common.SqlConvert::ConvertToSqlInt64