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


C# SqlDecimal.ToSqlByte方法代码示例

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


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

示例1: ToSqlByte

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

示例2: ToSqlByte

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

示例3: Conversions

        public void Conversions()
        {
            // ToDouble
            Assert.Equal(6464.6464, _test1.ToDouble());

            // ToSqlBoolean ()
            Assert.Equal(new SqlBoolean(1), _test1.ToSqlBoolean());

            SqlDecimal Test = new SqlDecimal(0);
            Assert.True(!Test.ToSqlBoolean().Value);

            Test = new SqlDecimal(0);
            Assert.True(!Test.ToSqlBoolean().Value);
            Assert.True(SqlDecimal.Null.ToSqlBoolean().IsNull);

            // ToSqlByte ()
            Test = new SqlDecimal(250);
            Assert.Equal((byte)250, Test.ToSqlByte().Value);

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

            // ToSqlDouble ()
            Assert.Equal(6464.6464, _test1.ToSqlDouble());

            // ToSqlInt16 ()
            Assert.Equal((short)1, new SqlDecimal(1).ToSqlInt16().Value);

            try
            {
                SqlInt16 test = SqlDecimal.MaxValue.ToSqlInt16().Value;
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlInt32 () 
            // LAMESPEC: 6464.6464 --> 64646464 ??? with windows
            // MS.NET seems to return the first 32 bit integer (i.e. 
            // Data [0]) but we don't have to follow such stupidity.
            //			Assert.Equal ((int)64646464, Test1.ToSqlInt32 ().Value);
            //			Assert.Equal ((int)1212, new SqlDecimal(12.12m).ToSqlInt32 ().Value);

            try
            {
                SqlInt32 test = SqlDecimal.MaxValue.ToSqlInt32().Value;
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlInt64 ()
            Assert.Equal(6464, _test1.ToSqlInt64().Value);

            // ToSqlMoney ()
            Assert.Equal((decimal)6464.6464, _test1.ToSqlMoney().Value);

            try
            {
                SqlMoney test = SqlDecimal.MaxValue.ToSqlMoney().Value;
                Assert.False(true);
            }
            catch (OverflowException e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            // ToSqlSingle ()
            Assert.Equal((float)6464.6464, _test1.ToSqlSingle().Value);

            // ToSqlString ()
            Assert.Equal("6464.6464", _test1.ToSqlString().Value);

            // ToString ()
            Assert.Equal("6464.6464", _test1.ToString());
            // NOT WORKING
            Assert.Equal("792281625142643375935439503350000.00", SqlDecimal.Multiply(_test5, _test2).ToString());
            Assert.Equal(1E+38, SqlDecimal.MaxValue.ToSqlDouble());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:90,代码来源:SqlDecimalTest.cs

示例4: Conversions

		public void Conversions ()
		{
			// ToDouble
			Assert.AreEqual (6464.6464, Test1.ToDouble (), "N01");

			// ToSqlBoolean ()
			Assert.AreEqual (new SqlBoolean (1), Test1.ToSqlBoolean (), "#N02");

			SqlDecimal Test = new SqlDecimal (0);
			Assert.IsTrue (!Test.ToSqlBoolean ().Value, "#N03");

			Test = new SqlDecimal (0);
			Assert.IsTrue (!Test.ToSqlBoolean ().Value, "#N04");
			Assert.IsTrue (SqlDecimal.Null.ToSqlBoolean ().IsNull, "#N05");

			// ToSqlByte ()
			Test = new SqlDecimal (250);
			Assert.AreEqual ((byte) 250, Test.ToSqlByte ().Value, "#N06");

			try {
				SqlByte b = (byte) Test2.ToSqlByte ();
				Assert.Fail ("#N07");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N08");
			}

			// ToSqlDouble ()
			Assert.AreEqual ((SqlDouble) 6464.6464, Test1.ToSqlDouble (), "#N09");

			// ToSqlInt16 ()
			Assert.AreEqual ((short) 1, new SqlDecimal (1).ToSqlInt16 ().Value, "#N10");

			try {
				SqlInt16 test = SqlDecimal.MaxValue.ToSqlInt16 ().Value;
				Assert.Fail ("#N11");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N12");
			}

			// ToSqlInt32 () 
			// LAMESPEC: 6464.6464 --> 64646464 ??? with windows
			// MS.NET seems to return the first 32 bit integer (i.e. 
			// Data [0]) but we don't have to follow such stupidity.
			//			Assert.AreEqual ((int)64646464, Test1.ToSqlInt32 ().Value, "#N13a");
			//			Assert.AreEqual ((int)1212, new SqlDecimal(12.12m).ToSqlInt32 ().Value, "#N13b");

			try {
				SqlInt32 test = SqlDecimal.MaxValue.ToSqlInt32 ().Value;
				Assert.Fail ("#N14");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N15");
			}

			// ToSqlInt64 ()
			Assert.AreEqual ((long) 6464, Test1.ToSqlInt64 ().Value, "#N16");

			// ToSqlMoney ()
			Assert.AreEqual ((decimal) 6464.6464, Test1.ToSqlMoney ().Value, "#N17");

			try {
				SqlMoney test = SqlDecimal.MaxValue.ToSqlMoney ().Value;
				Assert.Fail ("#N18");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N19");
			}

			// ToSqlSingle ()
			Assert.AreEqual ((float) 6464.6464, Test1.ToSqlSingle ().Value, "#N20");

			// ToSqlString ()
			Assert.AreEqual ("6464.6464", Test1.ToSqlString ().Value, "#N21");

			// ToString ()
			Assert.AreEqual ("6464.6464", Test1.ToString (), "#N22");
			// NOT WORKING
			Assert.AreEqual ("792281625142643375935439503350000.00", SqlDecimal.Multiply (Test5 , Test2).ToString () , "#N22.1");
			Assert.AreEqual ((SqlDouble) 1E+38, SqlDecimal.MaxValue.ToSqlDouble (), "#N23");

		}
开发者ID:jamescourtney,项目名称:mono,代码行数:79,代码来源:SqlDecimalTest.cs

示例5: Conversions

                public void Conversions()
                {
                	// ToDouble
                	AssertEquals ("N01", 6464.6464, Test1.ToDouble ());
                	
                        // ToSqlBoolean ()
                       	AssertEquals ("#N02", new SqlBoolean(1), Test1.ToSqlBoolean ());
                        
                        SqlDecimal Test = new SqlDecimal (0);
                        Assert ("#N03", !Test.ToSqlBoolean ().Value);
                	
                	Test = new SqlDecimal (0);
                	Assert ("#N04", !Test.ToSqlBoolean ().Value);
                        Assert ("#N05", SqlDecimal.Null.ToSqlBoolean ().IsNull);

                        // ToSqlByte ()
                        Test = new SqlDecimal (250);
                        AssertEquals ("#N06", (byte)250, Test.ToSqlByte ().Value);

                        try {
                                SqlByte b = (byte)Test2.ToSqlByte ();
                                Fail ("#N07");
                        } catch (Exception e) {
                                AssertEquals ("#N08", typeof (OverflowException), e.GetType ());
                        }

                        // ToSqlDouble ()
                        AssertEquals ("#N09", (SqlDouble)6464.6464, Test1.ToSqlDouble ());

                        // ToSqlInt16 ()
                        AssertEquals ("#N10", (short)1, new SqlDecimal (1).ToSqlInt16 ().Value);

                        try {
                                SqlInt16 test = SqlDecimal.MaxValue.ToSqlInt16().Value;
                                Fail ("#N11");
                        } catch (Exception e) {
                                AssertEquals ("#N12", typeof (OverflowException), e.GetType ());
                        }        

                        // ToSqlInt32 () 
                        // LAMESPEC: 6464.6464 --> 64646464 ??? with windows
			// MS.NET seems to return the first 32 bit integer (i.e. 
			// Data [0]) but we don't have to follow such stupidity.
//			AssertEquals ("#N13a", (int)64646464, Test1.ToSqlInt32 ().Value);
//			AssertEquals ("#N13b", (int)1212, new SqlDecimal(12.12m).ToSqlInt32 ().Value);
                	
                        try {
                                SqlInt32 test = SqlDecimal.MaxValue.ToSqlInt32 ().Value;
                                Fail ("#N14");
                        } catch (Exception e) { 
                                AssertEquals ("#N15", typeof (OverflowException), e.GetType ());
                        }

                        // ToSqlInt64 ()
                        AssertEquals ("#N16", (long)6464, Test1.ToSqlInt64 ().Value);

                        // ToSqlMoney ()
                        AssertEquals ("#N17", (decimal)6464.6464, Test1.ToSqlMoney ().Value);

                        try {
                                SqlMoney test = SqlDecimal.MaxValue.ToSqlMoney ().Value;
                                Fail ("#N18");
                        } catch (Exception e) {
                                AssertEquals ("#N19", typeof (OverflowException), e.GetType ());
                        }        

                        // ToSqlSingle ()
                        AssertEquals ("#N20", (float)6464.6464, Test1.ToSqlSingle ().Value);

                        // ToSqlString ()
                        AssertEquals ("#N21", "6464.6464", Test1.ToSqlString ().Value);

                        // ToString ()
                        AssertEquals ("#N22", "6464.6464", Test1.ToString ());                        
			AssertEquals ("#N23", (SqlDouble)1E+38, SqlDecimal.MaxValue.ToSqlDouble ());

                }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:77,代码来源:SqlDecimalTest.cs


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