本文整理汇总了C#中System.Data.SqlTypes.SqlInt32.ToSqlBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# SqlInt32.ToSqlBoolean方法的具体用法?C# SqlInt32.ToSqlBoolean怎么用?C# SqlInt32.ToSqlBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlInt32
的用法示例。
在下文中一共展示了SqlInt32.ToSqlBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlBoolean
/// <summary>
/// Converts the value of the specified SqlInt32 to its equivalent SqlBoolean representation.
/// </summary>
/// <param name="value">An SqlInt32.</param>
/// <returns>The equivalent SqlBoolean.</returns>
public static SqlBoolean ToSqlBoolean(SqlInt32 value) { return value.ToSqlBoolean(); }
示例2: ToSqlBoolean
/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlBoolean</c> value.</summary>
public static SqlBoolean ToSqlBoolean(SqlInt32 p) { return p.ToSqlBoolean(); }
示例3: ConversionMethods
public void ConversionMethods ()
{
SqlInt32 x;
// Case 1: SqlInt32.Null -> SqlBoolean == SqlBoolean.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlBoolean (), SqlBoolean.Null , "SqlInt32.Null -> SqlBoolean does not yield SqlBoolean.Null.");
// Case 2: SqlInt32.Zero -> SqlBoolean == False
x = SqlInt32.Zero;
Assert.AreEqual (x.ToSqlBoolean (), SqlBoolean.False , "SqlInt32.Zero -> SqlBoolean does not yield SqlBoolean.False.");
// Case 3: SqlInt32(nonzero) -> SqlBoolean == True
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlBoolean (), SqlBoolean.True , "SqlInt32 (27) -> SqlBoolean does not yield SqlBoolean.True.");
// Case 4: SqlInt32.Null -> SqlByte == SqlByte.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlByte (), SqlByte.Null , "SqlInt32.Null -> SqlByte does not yield SqlByte.Null.");
// Case 5: Test non-null conversion to SqlByte
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlByte ().Value, (byte)27, "SqlInt32 (27) -> SqlByte does not yield a value of 27");
// Case 6: SqlInt32.Null -> SqlDecimal == SqlDecimal.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlDecimal (), SqlDecimal.Null , "SqlInt32.Null -> SqlDecimal does not yield SqlDecimal.Null.");
// Case 7: Test non-null conversion to SqlDecimal
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlDecimal ().Value, (decimal)27, "SqlInt32 (27) -> SqlDecimal does not yield a value of 27");
// Case 8: SqlInt32.Null -> SqlDouble == SqlDouble.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlDouble (), SqlDouble.Null , "SqlInt32.Null -> SqlDouble does not yield SqlDouble.Null.");
// Case 9: Test non-null conversion to SqlDouble
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlDouble ().Value, (double)27, "SqlInt32 (27) -> SqlDouble does not yield a value of 27");
// Case 10: SqlInt32.Null -> SqlInt16 == SqlInt16.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlInt16 (), SqlInt16.Null , "SqlInt32.Null -> SqlInt16 does not yield SqlInt16.Null.");
// Case 11: Test non-null conversion to SqlInt16
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlInt16 ().Value, (short)27, "SqlInt32 (27) -> SqlInt16 does not yield a value of 27");
// Case 12: SqlInt32.Null -> SqlInt64 == SqlInt64.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlInt64 (), SqlInt64.Null , "SqlInt32.Null -> SqlInt64 does not yield SqlInt64.Null.");
// Case 13: Test non-null conversion to SqlInt64
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlInt64 ().Value, (long)27, "SqlInt32 (27) -> SqlInt64 does not yield a value of 27");
// Case 14: SqlInt32.Null -> SqlMoney == SqlMoney.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlMoney (), SqlMoney.Null , "SqlInt32.Null -> SqlMoney does not yield SqlMoney.Null.");
// Case 15: Test non-null conversion to SqlMoney
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlMoney ().Value, 27.0000M, "SqlInt32 (27) -> SqlMoney does not yield a value of 27");
// Case 16: SqlInt32.Null -> SqlSingle == SqlSingle.Null
x = SqlInt32.Null;
Assert.AreEqual (x.ToSqlSingle (), SqlSingle.Null , "SqlInt32.Null -> SqlSingle does not yield SqlSingle.Null.");
// Case 17: Test non-null conversion to SqlSingle
x = new SqlInt32 (27);
Assert.AreEqual (x.ToSqlSingle ().Value, (float)27, "SqlInt32 (27) -> SqlSingle does not yield a value of 27");
}
示例4: ConversionMethods
public void ConversionMethods()
{
SqlInt32 x;
// Case 1: SqlInt32.Null -> SqlBoolean == SqlBoolean.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlBoolean(), SqlBoolean.Null);
// Case 2: SqlInt32.Zero -> SqlBoolean == False
x = SqlInt32.Zero;
Assert.Equal(x.ToSqlBoolean(), SqlBoolean.False);
// Case 3: SqlInt32(nonzero) -> SqlBoolean == True
x = new SqlInt32(27);
Assert.Equal(x.ToSqlBoolean(), SqlBoolean.True);
// Case 4: SqlInt32.Null -> SqlByte == SqlByte.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlByte(), SqlByte.Null);
// Case 5: Test non-null conversion to SqlByte
x = new SqlInt32(27);
Assert.Equal(x.ToSqlByte().Value, (byte)27);
// Case 6: SqlInt32.Null -> SqlDecimal == SqlDecimal.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlDecimal(), SqlDecimal.Null);
// Case 7: Test non-null conversion to SqlDecimal
x = new SqlInt32(27);
Assert.Equal(x.ToSqlDecimal().Value, 27);
// Case 8: SqlInt32.Null -> SqlDouble == SqlDouble.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlDouble(), SqlDouble.Null);
// Case 9: Test non-null conversion to SqlDouble
x = new SqlInt32(27);
Assert.Equal(x.ToSqlDouble().Value, 27);
// Case 10: SqlInt32.Null -> SqlInt16 == SqlInt16.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlInt16(), SqlInt16.Null);
// Case 11: Test non-null conversion to SqlInt16
x = new SqlInt32(27);
Assert.Equal(x.ToSqlInt16().Value, (short)27);
// Case 12: SqlInt32.Null -> SqlInt64 == SqlInt64.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlInt64(), SqlInt64.Null);
// Case 13: Test non-null conversion to SqlInt64
x = new SqlInt32(27);
Assert.Equal(x.ToSqlInt64().Value, 27);
// Case 14: SqlInt32.Null -> SqlMoney == SqlMoney.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlMoney(), SqlMoney.Null);
// Case 15: Test non-null conversion to SqlMoney
x = new SqlInt32(27);
Assert.Equal(x.ToSqlMoney().Value, 27.0000M);
// Case 16: SqlInt32.Null -> SqlSingle == SqlSingle.Null
x = SqlInt32.Null;
Assert.Equal(x.ToSqlSingle(), SqlSingle.Null);
// Case 17: Test non-null conversion to SqlSingle
x = new SqlInt32(27);
Assert.Equal(x.ToSqlSingle().Value, 27);
}