System.Data.DataColumn.CompareValueTo C# (CSharp) Method

CompareValueTo() private method

private CompareValueTo ( int record1, object value, bool checkType ) : bool
record1 int
value object
checkType bool
return bool
        internal bool CompareValueTo(int record1, object value, bool checkType)
        {
            // this method is used to make sure value and exact type match.
            int valuesMatch = CompareValueTo(record1, value);

            // if values match according to storage, do extra checks for exact compare
            if (valuesMatch == 0)
            {
                Type leftType = value.GetType();
                Type rightType = _storage.Get(record1).GetType();
                // if strings, then do exact character by character check
                if (leftType == typeof(string) && rightType == typeof(string))
                {
                    return string.CompareOrdinal((string)_storage.Get(record1), (string)value) == 0 ? true : false;
                }
                // make sure same type
                else if (leftType == rightType)
                {
                    return true;
                }
            }

            return false;
        }

Same methods

DataColumn::CompareValueTo ( int record1, object value ) : int

Usage Example

Exemplo n.º 1
0
        private int FindNodeByKey(object?originalKey)
        {
            int x, c;

            if (_indexFields.Length != 1)
            {
                throw ExceptionBuilder.IndexKeyLength(_indexFields.Length, 1);
            }

            x = _records.root;
            if (IndexTree.NIL != x)
            {
                // otherwise storage may not exist
                DataColumn column = _indexFields[0].Column;
                object?    key    = column.ConvertValue(originalKey);

                x = _records.root;
                if (_indexFields[0].IsDescending)
                {
                    while (IndexTree.NIL != x)
                    {
                        c = column.CompareValueTo(_records.Key(x), key);
                        if (c == 0)
                        {
                            break;
                        }
                        if (c < 0)
                        {
                            x = _records.Left(x);
                        }                                    // < for decsending
                        else
                        {
                            x = _records.Right(x);
                        }
                    }
                }
                else
                {
                    while (IndexTree.NIL != x)
                    {
                        c = column.CompareValueTo(_records.Key(x), key);
                        if (c == 0)
                        {
                            break;
                        }
                        if (c > 0)
                        {
                            x = _records.Left(x);
                        }                                    // > for ascending
                        else
                        {
                            x = _records.Right(x);
                        }
                    }
                }
            }
            return(x);
        }
All Usage Examples Of System.Data.DataColumn::CompareValueTo