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


C# SqlString.CompareTo方法代码示例

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


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

示例1: SqlStringDefaultCompareOptionTest

        // Special characters matching test for default option (SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth)
        private static void SqlStringDefaultCompareOptionTest(int localeID)
        {
            SqlString str1;
            SqlString str2;

            for (int i = 0; i < s_specialMatchingString.GetLength(0); ++i)
            {
                // SqlString(string) creates instance with the default comparison options
                str1 = new SqlString(s_specialMatchingString[i, 0], localeID);
                str2 = new SqlString(s_specialMatchingString[i, 1], localeID);

                // Per default option, each set contains two string which should be matched as equal per default option
                Assert.True((bool)(str1 == str2), string.Format("Error (Default Comparison Option with Operator): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1]));
                Assert.True(str1.CompareTo(str2) == 0, string.Format("FAILED: (Default Comparison Option with CompareTo): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1]));
            }
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:17,代码来源:SqlTypeTest.cs

示例2: SqlStringNullComparisonTest

        public static void SqlStringNullComparisonTest()
        {
            SqlString nullSqlString = new SqlString(null);
            SqlString nonNullSqlString = new SqlString("abc   ");

            Assert.True(
                (bool)(nullSqlString < nonNullSqlString
                || nonNullSqlString >= nullSqlString
                || nullSqlString.CompareTo(nonNullSqlString) < 0
                || nonNullSqlString.CompareTo(nullSqlString) >= 0),
                "FAILED: (SqlString Null Comparison): Null SqlString not equal to null");

            Assert.True((nullSqlString == null && nullSqlString.CompareTo(null) == 0).IsNull, "FAILED: (SqlString Null Comparison): Null SqlString not equal to null");
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:14,代码来源:SqlTypeTest.cs

示例3: CompareToSqlTypeException

		public void CompareToSqlTypeException ()
		{
			SqlString T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
			SqlString T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
			T1.CompareTo (T2);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:SqlStringTest.cs

示例4: CompareTo

		public void CompareTo()
		{
			SqlByte Test = new SqlByte (1);

			Assert.IsTrue (Test1.CompareTo (Test3) < 0, "#D01");
			Assert.IsTrue (Test2.CompareTo (Test1) > 0, "#D02");
			Assert.IsTrue (Test2.CompareTo (Test3) == 0, "#D03");
			Assert.IsTrue (Test3.CompareTo (SqlString.Null) > 0, "#D04");

			SqlString T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
			SqlString T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);

			// IgnoreCase
			T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
			T2 = new SqlString ("TEST", 2057, SqlCompareOptions.IgnoreCase);
			Assert.IsTrue (T2.CompareTo (T1) == 0, "#D09");

			T1 = new SqlString ("test", 2057);
			T2 = new SqlString ("TEST", 2057);
			Assert.IsTrue (T2.CompareTo (T1) == 0, "#D10");

			T1 = new SqlString ("test", 2057, SqlCompareOptions.None);
			T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
			Assert.IsTrue (T2.CompareTo (T1) != 0, "#D11");

			// IgnoreNonSpace
			T1 = new SqlString ("TEST\xF1", 2057, SqlCompareOptions.IgnoreNonSpace);
			T2 = new SqlString ("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace);
			Assert.IsTrue (T2.CompareTo (T1) == 0, "#D12");

			T1 = new SqlString ("TESTñ", 2057, SqlCompareOptions.None);
			T2 = new SqlString ("TESTn", 2057, SqlCompareOptions.None);
			Assert.IsTrue (T2.CompareTo (T1) != 0, "#D13");

			// BinarySort
			T1 = new SqlString ("01_", 2057, SqlCompareOptions.BinarySort);
			T2 = new SqlString ("_01", 2057, SqlCompareOptions.BinarySort);
			Assert.IsTrue (T1.CompareTo (T2) < 0, "#D14");

			T1 = new SqlString ("01_", 2057, SqlCompareOptions.None);
			T2 = new SqlString ("_01", 2057, SqlCompareOptions.None);
			Assert.IsTrue (T1.CompareTo (T2) > 0, "#D15");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:43,代码来源:SqlStringTest.cs

示例5: LessThanOrEqual

        /**
         * Compares two instances of SqlString to determine if the first is less than the second.
         * @param x A SqlString instance
         * @param y A SqlString instance
         * @return A SqlBoolean that is True if the first instance is less than the second instance, otherwise False.
         * If either instance of SqlString is null, the Value of the SqlBoolean will be Null.
         */
        public static SqlBoolean LessThanOrEqual(SqlString x, SqlString y)
        {
            if (x.IsNull || y.IsNull)
                return SqlBoolean.Null;

            if (x.CompareTo(y) <= 0)
                return SqlBoolean.True;

            return SqlBoolean.False;
        }
开发者ID:runefs,项目名称:Marvin,代码行数:17,代码来源:SqlString.cs

示例6: GreaterThan

        /**
         * Compares two instances of SqlString to determine if the first is greater than the second.
         * @param x A SqlString instance
         * @param y A SqlString instance
         * @return A SqlBoolean that is True if the first instance is greater than the second instance, otherwise False.
         * If either instance of SqlString is null, the Value of the SqlBoolean will be Null.
         */
        public static SqlBoolean GreaterThan(SqlString x, SqlString y)
        {
            if (x.IsNull || y.IsNull)
                return SqlBoolean.Null;

            if (x.CompareTo(y) > 0)
                return SqlBoolean.True;

            return SqlBoolean.False;
        }
开发者ID:runefs,项目名称:Marvin,代码行数:17,代码来源:SqlString.cs

示例7: CompareTo

        public void CompareTo()
        {
            SqlByte Test = new SqlByte(1);

            Assert.True(_test1.CompareTo(_test3) < 0);
            Assert.True(_test2.CompareTo(_test1) > 0);
            Assert.True(_test2.CompareTo(_test3) == 0);
            Assert.True(_test3.CompareTo(SqlString.Null) > 0);

            SqlString T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase);
            SqlString T2 = new SqlString("TEST", 2057, SqlCompareOptions.None);

            // IgnoreCase
            T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase);
            T2 = new SqlString("TEST", 2057, SqlCompareOptions.IgnoreCase);
            Assert.True(T2.CompareTo(T1) == 0);

            T1 = new SqlString("test", 2057);
            T2 = new SqlString("TEST", 2057);
            Assert.True(T2.CompareTo(T1) == 0);

            T1 = new SqlString("test", 2057, SqlCompareOptions.None);
            T2 = new SqlString("TEST", 2057, SqlCompareOptions.None);
            Assert.True(T2.CompareTo(T1) != 0);

            // IgnoreNonSpace
            T1 = new SqlString("TEST\xF1", 2057, SqlCompareOptions.IgnoreNonSpace);
            T2 = new SqlString("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace);
            Assert.True(T2.CompareTo(T1) == 0);

            T1 = new SqlString("TEST\u00F1", 2057, SqlCompareOptions.None);
            T2 = new SqlString("TESTn", 2057, SqlCompareOptions.None);
            Assert.True(T2.CompareTo(T1) != 0);

            // BinarySort
            T1 = new SqlString("01_", 2057, SqlCompareOptions.BinarySort);
            T2 = new SqlString("_01", 2057, SqlCompareOptions.BinarySort);
            Assert.True(T1.CompareTo(T2) < 0);

            T1 = new SqlString("01_", 2057, SqlCompareOptions.None);
            T2 = new SqlString("_01", 2057, SqlCompareOptions.None);
            Assert.True(T1.CompareTo(T2) > 0);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:43,代码来源:SqlStringTest.cs

示例8: CompareToSqlTypeException

 public void CompareToSqlTypeException()
 {
     SqlString T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase);
     SqlString T2 = new SqlString("TEST", 2057, SqlCompareOptions.None);
     Assert.Throws<SqlTypeException>(() => T1.CompareTo(T2));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:SqlStringTest.cs

示例9: CompareToSqlTypeException

		public void CompareToSqlTypeException ()
		{
		    ExceptionAssert.Throws<SqlTypeException>(
		        delegate
		            {
		                SqlString T1 = new SqlString("test", "en-GB", SqlCompareOptions.IgnoreCase);
		                SqlString T2 = new SqlString("TEST", "en-GB", SqlCompareOptions.None);
		                T1.CompareTo(T2);
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:10,代码来源:SqlStringTest.cs


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