Partager via


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

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

Namespace:  Microsoft.VisualStudio.Data.Framework
Assembly:  Microsoft.VisualStudio.Data.Framework (in Microsoft.VisualStudio.Data.Framework.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[]

    An array of data source object identifier parts.

  • 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
A value less than zero if the identifier part is less than the specified value; zero if the identifier part is equal to the specified value; a value greater than zero if the identifier part is greater than the specified value.

Implements

IVsDataObjectMemberComparer.Compare(String, array<Object[], Int32, Object)

Exceptions

Exception Condition
ArgumentNullException

The typeName and/or identifier parameter is nulla null reference (Nothing in Visual Basic).

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.

If you pass in the complete source identifier, you can handle certain complex situations. 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 appear as the second and third parts respectively in a full table identifier, the first part being the database), the implementation of this method must use the first identifier part to determine which database the table is in, and thus, what kind of comparison to use.

The base implementation of this method uses the default .NET Framework 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 null and DBNull identically. That is, if one value is DBNull and the other value is null, they are considered the same value.

.NET Framework Security

See Also

Reference

DataObjectMemberComparer Class

Compare Overload

Microsoft.VisualStudio.Data.Framework Namespace