Delen via


DataObjectItemComparer.Compare Method (String, array<Object , Int32, Object)

Compares one object identifier part with another specified object identifier part.

Namespace:  Microsoft.VisualStudio.Data
Assembly:  Microsoft.VisualStudio.Data (in Microsoft.VisualStudio.Data.dll)

Syntax

'Declaration
Public Overridable Function Compare ( _
    typeName As String, _
    identifier As Object(), _
    identifierPart As Integer, _
    value As Object _
) As Integer
public virtual int Compare(
    string typeName,
    Object[] identifier,
    int identifierPart,
    Object value
)
public:
virtual int Compare(
    String^ typeName, 
    array<Object^>^ identifier, 
    int identifierPart, 
    Object^ value
)
abstract Compare : 
        typeName:string * 
        identifier:Object[] * 
        identifierPart:int * 
        value:Object -> int  
override Compare : 
        typeName:string * 
        identifier:Object[] * 
        identifierPart:int * 
        value:Object -> int
public function Compare(
    typeName : String, 
    identifier : Object[], 
    identifierPart : int, 
    value : Object
) : int

Parameters

  • identifier
    Type: array<System.Object[]

    The identifier of an object of the type specified by typeName parameter.

  • identifierPart
    Type: System.Int32

    The zero based index into the identifier array indicating which part of the identifier to compare.

  • value
    Type: System.Object

    A value to compare the identifier part against.

Return Value

Type: System.Int32
Returns less than zero in cases where the identifier part is less than the specified value. Returns zero if the identifier part is equal to the specified value. Returns greater than zero if the identifier part is greater than the specified value.

Exceptions

Exception Condition
ArgumentNullException

The typeName and/or identifier parameter is null.

ArgumentOutOfRangeException

The identifier parameter is less than zero or greater than or equal to the number of elements in the identifier array.

Remarks

This method should use the same comparison rules as the data source to ensure the correct uniqueness of objects on the client side.

By passing in the complete source identifier, certain complex situations can be handled. For example, recent versions of Microsoft SQL Server will allow the server as a whole to be case sensitive on identifier comparison while a particular database on the server may be case insensitive, or vice versa. This means that when comparing the schema or name of a table (which appears as the second and third parts in a full table identifier, the first part being the database), the implementation of this method must use the first identifier part to figure out which database the table is in, and thus, what kind of comparison to use.

The base implementation of this method uses the default .NET object comparer (Comparer) when the source identifier part implements IComparable; otherwise it calls the IComparable implementation's override Equals method and returns 1 if this method returns false.

This method treats nulla null reference (Nothing in Visual Basic) and DBNull identically. That is, if one value is DBNull and the other value is nulla null reference (Nothing in Visual Basic), they are considered the same value.

.NET Framework Security

See Also

Reference

DataObjectItemComparer Class

Compare Overload

Microsoft.VisualStudio.Data Namespace