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


C# SqlString.SetCompareInfo方法代码示例

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


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

示例1: StringCompare

        // StringCompare: Common compare function which is used by Compare and CompareTo
        //  In the case of Compare (used by comparison operators) the int result needs to be converted to SqlBoolean type
        //  while CompareTo needs the result in int type
        //  Pre-requisite: the null condition of the both string needs to be checked and handled by the caller of this function
        private static int StringCompare(SqlString x, SqlString y)
        {
            Debug.Assert(!x.IsNull && !y.IsNull, "Null condition should be handled by the caller of StringCompare method");

            if (x._lcid != y._lcid || x._flag != y._flag)
                throw new SqlTypeException(SQLResource.CompareDiffCollationMessage);

            x.SetCompareInfo();
            y.SetCompareInfo();
            Debug.Assert(x.FBinarySort() || (x._cmpInfo != null && y._cmpInfo != null));

            int iCmpResult;

            if ((x._flag & SqlCompareOptions.BinarySort) != 0)
                iCmpResult = CompareBinary(x, y);
            else if ((x._flag & SqlCompareOptions.BinarySort2) != 0)
                iCmpResult = CompareBinary2(x, y);
            else
            {
                // SqlString can be padded with spaces (Padding is turn on by default in SQL Server 2008
                // Trim the trailing space for comparison
                //  Avoid using String.TrimEnd function to avoid extra string allocations

                string rgchX = x._value;
                string rgchY = y._value;
                int cwchX = rgchX.Length;
                int cwchY = rgchY.Length;

                while (cwchX > 0 && rgchX[cwchX - 1] == ' ')
                    cwchX--;
                while (cwchY > 0 && rgchY[cwchY - 1] == ' ')
                    cwchY--;

                CompareOptions options = CompareOptionsFromSqlCompareOptions(x._flag);

                iCmpResult = x._cmpInfo.Compare(x._value, 0, cwchX, y._value, 0, cwchY, options);
            }

            return iCmpResult;
        }
开发者ID:natemcmaster,项目名称:corefx,代码行数:44,代码来源:SQLString.cs

示例2: StringCompare

 private static int StringCompare(SqlString x, SqlString y)
 {
     if ((x.m_lcid != y.m_lcid) || (x.m_flag != y.m_flag))
     {
         throw new SqlTypeException(SQLResource.CompareDiffCollationMessage);
     }
     x.SetCompareInfo();
     y.SetCompareInfo();
     if ((x.m_flag & System.Data.SqlTypes.SqlCompareOptions.BinarySort) != System.Data.SqlTypes.SqlCompareOptions.None)
     {
         return CompareBinary(x, y);
     }
     if ((x.m_flag & System.Data.SqlTypes.SqlCompareOptions.BinarySort2) != System.Data.SqlTypes.SqlCompareOptions.None)
     {
         return CompareBinary2(x, y);
     }
     char[] chArray2 = x.m_value.ToCharArray();
     char[] chArray = y.m_value.ToCharArray();
     int length = chArray2.Length;
     int num = chArray.Length;
     while ((length > 0) && (chArray2[length - 1] == ' '))
     {
         length--;
     }
     while ((num > 0) && (chArray[num - 1] == ' '))
     {
         num--;
     }
     CompareOptions options = CompareOptionsFromSqlCompareOptions(x.m_flag);
     return x.m_cmpInfo.Compare(x.m_value, 0, length, y.m_value, 0, num, options);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:SqlString.cs


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