System.Data.SqlTypes.SqlString.FBinarySort C# (CSharp) Method

FBinarySort() private method

private FBinarySort ( ) : bool
return bool
        private bool FBinarySort()
        {
            return (!IsNull && (_flag & (SqlCompareOptions.BinarySort | SqlCompareOptions.BinarySort2)) != 0);
        }

Usage Example

Ejemplo n.º 1
0
        // 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)
        {
            SQLDebug.Check(!x.IsNull && !y.IsNull,
                           "!x.IsNull && !y.IsNull", "Null condition should be handled by the caller of StringCompare method");

            if (x.m_lcid != y.m_lcid || x.m_flag != y.m_flag)
            {
                throw new SqlTypeException(SQLResource.CompareDiffCollationMessage);
            }

            x.SetCompareInfo();
            y.SetCompareInfo();
            SQLDebug.Check(x.FBinarySort() || (x.m_cmpInfo != null && y.m_cmpInfo != null),
                           "x.FBinarySort() || (x.m_cmpInfo != null && y.m_cmpInfo != null)", "");

            int iCmpResult;

            if ((x.m_flag & SqlCompareOptions.BinarySort) != 0)
            {
                iCmpResult = CompareBinary(x, y);
            }
            else if ((x.m_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.m_value;
                string rgchY = y.m_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.m_flag);

                iCmpResult = x.m_cmpInfo.Compare(x.m_value, 0, cwchX, y.m_value, 0, cwchY, options);
            }

            return(iCmpResult);
        }
All Usage Examples Of System.Data.SqlTypes.SqlString::FBinarySort