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


C# SqlInt64.ToSqlDecimal方法代码示例

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


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

示例1: Conversions

		public void Conversions ()
		{
			SqlInt64 Test12 = new SqlInt64 (12);
			SqlInt64 Test0 = new SqlInt64 (0);
			SqlInt64 TestNull = SqlInt64.Null;
			SqlInt64 Test1000 = new SqlInt64 (1000);
			SqlInt64 Test288 = new SqlInt64 (288);

			// ToSqlBoolean ()
			Assert.IsTrue (Test12.ToSqlBoolean ().Value, "#P01");
			Assert.IsTrue (!Test0.ToSqlBoolean ().Value, "#P02");
			Assert.IsTrue (TestNull.ToSqlBoolean ().IsNull, "#P03");

			// ToSqlByte ()
			Assert.AreEqual ((byte) 12, Test12.ToSqlByte ().Value, "#P04");
			Assert.AreEqual ((byte) 0, Test0.ToSqlByte ().Value, "#P05");

			try {
				SqlByte b = (byte) Test1000.ToSqlByte ();
				Assert.Fail ("#P06");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#P07");
			}

			// ToSqlDecimal ()
			Assert.AreEqual ((decimal) 12, Test12.ToSqlDecimal ().Value, "#P08");
			Assert.AreEqual ((decimal) 0, Test0.ToSqlDecimal ().Value, "#P09");
			Assert.AreEqual ((decimal) 288, Test288.ToSqlDecimal ().Value, "#P10");

			// ToSqlDouble ()
			Assert.AreEqual ((double) 12, Test12.ToSqlDouble ().Value, "#P11");
			Assert.AreEqual ((double) 0, Test0.ToSqlDouble ().Value, "#P12");
			Assert.AreEqual ((double) 1000, Test1000.ToSqlDouble ().Value, "#P13");

			// ToSqlInt32 ()
			Assert.AreEqual ((int) 12, Test12.ToSqlInt32 ().Value, "#P14");
			Assert.AreEqual ((int) 0, Test0.ToSqlInt32 ().Value, "#P15");
			Assert.AreEqual ((int) 288, Test288.ToSqlInt32 ().Value, "#P16");

			// ToSqlInt16 ()
			Assert.AreEqual ((short) 12, Test12.ToSqlInt16 ().Value, "#P17");
			Assert.AreEqual ((short) 0, Test0.ToSqlInt16 ().Value, "#P18");
			Assert.AreEqual ((short) 288, Test288.ToSqlInt16 ().Value, "#P19");

			// ToSqlMoney ()
			Assert.AreEqual (12.0000M, Test12.ToSqlMoney ().Value, "#P20");
			Assert.AreEqual ((decimal) 0, Test0.ToSqlMoney ().Value, "#P21");
			Assert.AreEqual (288.0000M, Test288.ToSqlMoney ().Value, "#P22");

			// ToSqlSingle ()
			Assert.AreEqual ((float) 12, Test12.ToSqlSingle ().Value, "#P23");
			Assert.AreEqual ((float) 0, Test0.ToSqlSingle ().Value, "#P24");
			Assert.AreEqual ((float) 288, Test288.ToSqlSingle ().Value, "#P25");

			// ToSqlString ()
			Assert.AreEqual ("12", Test12.ToSqlString ().Value, "#P26");
			Assert.AreEqual ("0", Test0.ToSqlString ().Value, "#P27");
			Assert.AreEqual ("288", Test288.ToSqlString ().Value, "#P28");

			// ToString ()
			Assert.AreEqual ("12", Test12.ToString (), "#P29");
			Assert.AreEqual ("0", Test0.ToString (), "#P30");
			Assert.AreEqual ("288", Test288.ToString (), "#P31");
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:64,代码来源:SqlInt64Test.cs

示例2: ToSqlDecimal

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

示例3: ToSqlDecimal

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

示例4: Conversions

        public void Conversions()
        {
            SqlInt64 Test12 = new SqlInt64(12);
            SqlInt64 Test0 = new SqlInt64(0);
            SqlInt64 TestNull = SqlInt64.Null;
            SqlInt64 Test1000 = new SqlInt64(1000);
            SqlInt64 Test288 = new SqlInt64(288);

            // ToSqlBoolean ()
            Assert.True(Test12.ToSqlBoolean().Value);
            Assert.True(!Test0.ToSqlBoolean().Value);
            Assert.True(TestNull.ToSqlBoolean().IsNull);

            // ToSqlByte ()
            Assert.Equal((byte)12, Test12.ToSqlByte().Value);
            Assert.Equal((byte)0, Test0.ToSqlByte().Value);

            try
            {
                SqlByte b = (byte)Test1000.ToSqlByte();
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlDecimal ()
            Assert.Equal(12, Test12.ToSqlDecimal().Value);
            Assert.Equal(0, Test0.ToSqlDecimal().Value);
            Assert.Equal(288, Test288.ToSqlDecimal().Value);

            // ToSqlDouble ()
            Assert.Equal(12, Test12.ToSqlDouble().Value);
            Assert.Equal(0, Test0.ToSqlDouble().Value);
            Assert.Equal(1000, Test1000.ToSqlDouble().Value);

            // ToSqlInt32 ()
            Assert.Equal(12, Test12.ToSqlInt32().Value);
            Assert.Equal(0, Test0.ToSqlInt32().Value);
            Assert.Equal(288, Test288.ToSqlInt32().Value);

            // ToSqlInt16 ()
            Assert.Equal((short)12, Test12.ToSqlInt16().Value);
            Assert.Equal((short)0, Test0.ToSqlInt16().Value);
            Assert.Equal((short)288, Test288.ToSqlInt16().Value);

            // ToSqlMoney ()
            Assert.Equal(12.0000M, Test12.ToSqlMoney().Value);
            Assert.Equal(0, Test0.ToSqlMoney().Value);
            Assert.Equal(288.0000M, Test288.ToSqlMoney().Value);

            // ToSqlSingle ()
            Assert.Equal(12, Test12.ToSqlSingle().Value);
            Assert.Equal(0, Test0.ToSqlSingle().Value);
            Assert.Equal(288, Test288.ToSqlSingle().Value);

            // ToSqlString ()
            Assert.Equal("12", Test12.ToSqlString().Value);
            Assert.Equal("0", Test0.ToSqlString().Value);
            Assert.Equal("288", Test288.ToSqlString().Value);

            // ToString ()
            Assert.Equal("12", Test12.ToString());
            Assert.Equal("0", Test0.ToString());
            Assert.Equal("288", Test288.ToString());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:67,代码来源:SqlInt64Test.cs


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