本文整理汇总了C#中System.Data.SqlTypes.SqlDouble.ToSqlInt64方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDouble.ToSqlInt64方法的具体用法?C# SqlDouble.ToSqlInt64怎么用?C# SqlDouble.ToSqlInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlDouble
的用法示例。
在下文中一共展示了SqlDouble.ToSqlInt64方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlInt64
/// <summary>
/// Converts the value of the specified SqlDouble to its equivalent SqlInt64 representation.
/// </summary>
/// <param name="value">An SqlDouble.</param>
/// <returns>The equivalent SqlInt64.</returns>
public static SqlInt64 ToSqlInt64(SqlDouble value) { return value.ToSqlInt64(); }
示例2: Conversions
public void Conversions()
{
SqlDouble Test0 = new SqlDouble (0);
SqlDouble Test1 = new SqlDouble (250);
SqlDouble Test2 = new SqlDouble (64e64);
SqlDouble Test3 = new SqlDouble (64e164);
SqlDouble TestNull = SqlDouble.Null;
// ToSqlBoolean ()
Assert ("#M01A", Test1.ToSqlBoolean ().Value);
Assert ("#M02A", !Test0.ToSqlBoolean ().Value);
Assert ("#M03A", TestNull.ToSqlBoolean ().IsNull);
// ToSqlByte ()
AssertEquals ("#M01B", (byte)250, Test1.ToSqlByte ().Value);
AssertEquals ("#M02B", (byte)0, Test0.ToSqlByte ().Value);
try {
SqlByte b = (byte)Test2.ToSqlByte ();
Fail ("#M03B");
} catch (Exception e) {
AssertEquals ("#M04B", typeof (OverflowException), e.GetType ());
}
// ToSqlDecimal ()
AssertEquals ("#M01C", 250.00000000000000M, Test1.ToSqlDecimal ().Value);
AssertEquals ("#M02C", (decimal)0, Test0.ToSqlDecimal ().Value);
try {
SqlDecimal test = Test3.ToSqlDecimal ().Value;
Fail ("#M03C");
} catch (Exception e) {
AssertEquals ("#M04C", typeof (OverflowException), e.GetType ());
}
// ToSqlInt16 ()
AssertEquals ("#M01D", (short)250, Test1.ToSqlInt16 ().Value);
AssertEquals ("#M02D", (short)0, Test0.ToSqlInt16 ().Value);
try {
SqlInt16 test = Test2.ToSqlInt16().Value;
Fail ("#M03D");
} catch (Exception e) {
AssertEquals ("#M04D", typeof (OverflowException), e.GetType ());
}
// ToSqlInt32 ()
AssertEquals ("#M01E", (int)250, Test1.ToSqlInt32 ().Value);
AssertEquals ("#M02E", (int)0, Test0.ToSqlInt32 ().Value);
try {
SqlInt32 test = Test2.ToSqlInt32 ().Value;
Fail ("#M03E");
} catch (Exception e) {
AssertEquals ("#M04E", typeof (OverflowException), e.GetType ());
}
// ToSqlInt64 ()
AssertEquals ("#M01F", (long)250, Test1.ToSqlInt64 ().Value);
AssertEquals ("#M02F", (long)0, Test0.ToSqlInt64 ().Value);
try {
SqlInt64 test = Test2.ToSqlInt64 ().Value;
Fail ("#M03F");
} catch (Exception e) {
AssertEquals ("#M04F", typeof (OverflowException), e.GetType ());
}
// ToSqlMoney ()
AssertEquals ("#M01G", 250.0000M, Test1.ToSqlMoney ().Value);
AssertEquals ("#M02G", (decimal)0, Test0.ToSqlMoney ().Value);
try {
SqlMoney test = Test2.ToSqlMoney ().Value;
Fail ("#M03G");
} catch (Exception e) {
AssertEquals ("#M04G", typeof (OverflowException), e.GetType ());
}
// ToSqlSingle ()
AssertEquals ("#M01H", (float)250, Test1.ToSqlSingle ().Value);
AssertEquals ("#M02H", (float)0, Test0.ToSqlSingle ().Value);
try {
SqlSingle test = Test2.ToSqlSingle().Value;
Fail ("#MO3H");
} catch (Exception e) {
AssertEquals ("#M04H", typeof (OverflowException), e.GetType ());
}
// ToSqlString ()
AssertEquals ("#M01I", "250", Test1.ToSqlString ().Value);
AssertEquals ("#M02I", "0", Test0.ToSqlString ().Value);
AssertEquals ("#M03I", "6.4E+65", Test2.ToSqlString ().Value);
// ToString ()
AssertEquals ("#M01J", "250", Test1.ToString ());
AssertEquals ("#M02J", "0", Test0.ToString ());
AssertEquals ("#M03J", "6.4E+65", Test2.ToString ());
}
示例3: ToSqlInt64
/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlInt64</c> value.</summary>
public static SqlInt64 ToSqlInt64(SqlDouble p) { return p.ToSqlInt64(); }
示例4: Conversions
public void Conversions()
{
SqlDouble Test0 = new SqlDouble(0);
SqlDouble Test1 = new SqlDouble(250);
SqlDouble Test2 = new SqlDouble(64e64);
SqlDouble Test3 = new SqlDouble(64e164);
SqlDouble TestNull = SqlDouble.Null;
// ToSqlBoolean ()
Assert.True(Test1.ToSqlBoolean().Value);
Assert.True(!Test0.ToSqlBoolean().Value);
Assert.True(TestNull.ToSqlBoolean().IsNull);
// ToSqlByte ()
Assert.Equal((byte)250, Test1.ToSqlByte().Value);
Assert.Equal((byte)0, Test0.ToSqlByte().Value);
try
{
SqlByte b = (byte)Test2.ToSqlByte();
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlDecimal ()
Assert.Equal(250.00000000000000M, Test1.ToSqlDecimal().Value);
Assert.Equal(0, Test0.ToSqlDecimal().Value);
try
{
SqlDecimal test = Test3.ToSqlDecimal().Value;
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlInt16 ()
Assert.Equal((short)250, Test1.ToSqlInt16().Value);
Assert.Equal((short)0, Test0.ToSqlInt16().Value);
try
{
SqlInt16 test = Test2.ToSqlInt16().Value;
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlInt32 ()
Assert.Equal(250, Test1.ToSqlInt32().Value);
Assert.Equal(0, Test0.ToSqlInt32().Value);
try
{
SqlInt32 test = Test2.ToSqlInt32().Value;
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlInt64 ()
Assert.Equal(250, Test1.ToSqlInt64().Value);
Assert.Equal(0, Test0.ToSqlInt64().Value);
try
{
SqlInt64 test = Test2.ToSqlInt64().Value;
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlMoney ()
Assert.Equal(250.0000M, Test1.ToSqlMoney().Value);
Assert.Equal(0, Test0.ToSqlMoney().Value);
try
{
SqlMoney test = Test2.ToSqlMoney().Value;
Assert.False(true);
}
catch (OverflowException e)
{
Assert.Equal(typeof(OverflowException), e.GetType());
}
// ToSqlSingle ()
Assert.Equal(250, Test1.ToSqlSingle().Value);
Assert.Equal(0, Test0.ToSqlSingle().Value);
//.........这里部分代码省略.........