当前位置: 首页>>代码示例>>C#>>正文


C# SqlInt32.ToSqlByte方法代码示例

本文整理汇总了C#中System.Data.SqlTypes.SqlInt32.ToSqlByte方法的典型用法代码示例。如果您正苦于以下问题:C# SqlInt32.ToSqlByte方法的具体用法?C# SqlInt32.ToSqlByte怎么用?C# SqlInt32.ToSqlByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlTypes.SqlInt32的用法示例。


在下文中一共展示了SqlInt32.ToSqlByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToSqlByte

 /// <summary>
 /// Converts the value of the specified SqlInt32 to its equivalent SqlByte representation.
 /// </summary>
 /// <param name="value">An SqlInt32.</param>
 /// <returns>The equivalent SqlByte.</returns>
 public static SqlByte ToSqlByte(SqlInt32 value) { return value.ToSqlByte(); }
开发者ID:mstaessen,项目名称:fluorinefx,代码行数:6,代码来源:Convert.cs

示例2: 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");
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:72,代码来源:SqlInt32Test.cs

示例3: ToSqlByte

		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlInt32   p) { return p.ToSqlByte();                                              }
开发者ID:titolarz,项目名称:bltoolkit,代码行数:2,代码来源:Convert.generated.cs

示例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);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:72,代码来源:SqlInt32Test.cs


注:本文中的System.Data.SqlTypes.SqlInt32.ToSqlByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。