Udostępnij za pośrednictwem


ReplicaMetadata.FindItemMetadataByUniqueIndexedFields Method

When overridden in a derived class, returns the unique item metadata entry that has the specified values for the indexed fields.

Namespace: Microsoft.Synchronization.MetadataStorage
Assembly: Microsoft.Synchronization.MetadataStorage (in microsoft.synchronization.metadatastorage.dll)

Syntax

'Declaration
Public MustOverride Function FindItemMetadataByUniqueIndexedFields ( _
    fields As IEnumerable(Of KeyValuePair(Of String, Object)) _
) As ItemMetadata
'Usage
Dim instance As ReplicaMetadata
Dim fields As IEnumerable(Of KeyValuePair(Of String, Object))
Dim returnValue As ItemMetadata

returnValue = instance.FindItemMetadataByUniqueIndexedFields(fields)
public abstract ItemMetadata FindItemMetadataByUniqueIndexedFields (
    IEnumerable<KeyValuePair<string,Object>> fields
)
public:
virtual ItemMetadata^ FindItemMetadataByUniqueIndexedFields (
    IEnumerable<KeyValuePair<String^, Object^>>^ fields
) abstract
public abstract ItemMetadata FindItemMetadataByUniqueIndexedFields (
    IEnumerable<KeyValuePair<String,Object>> fields
)
public abstract function FindItemMetadataByUniqueIndexedFields (
    fields : IEnumerable<KeyValuePair<String,Object>>
) : ItemMetadata

Parameters

  • fields
    The set of unique indexed fields that identifies the item for which to search. The fields must be valid fields and represent a unique index. These fields must be in the same order as that used to specify the index when InitializeReplicaMetadata was called.

Return Value

The unique item metadata entry that has the specified values for the indexed fields. A null reference (Nothing in Visual Basic) is returned when no item exists.

Exceptions

Exception type Condition

ObjectDisposedException

The object has been disposed or was not initialized correctly.

ArgumentNullException

fields is a null reference (Nothing in Visual Basic), or any name or value in fields is a null reference (Nothing in Visual Basic).

ArgumentException

A field name in fields is 0 length, or a string type value in fields is 0 length.

NotSupportedException

A field in fields is of an unsupported type.

MetadataFieldNotFoundException

fieldName was not found or is not valid.

MetadataStoreInvalidOperationException

The specified field is not a unique index.

Remarks

Custom fields must be established when the replica metadata is first initialized by passing FieldSchema to InitializeReplicaMetadata.

Index fields must be established and marked as unique when the replica metadata is first initialized by passing IndexSchema to InitializeReplicaMetadata.

Example

The following example creates a list of index field name and value pairs, and uses the list as a unique index to find an item in the metadata store:

private ItemMetadata FindMetadata(Contact contact)
{
    // Try to find the item by using the unique index field values of the contact. These values are
    // the first name, last name, and phone number of the contact.
    List<KeyValuePair<string, object>> fields = new List<KeyValuePair<string, object>>();
    fields.Add(new KeyValuePair<string, object>(FirstNameField, contact.FirstName));
    fields.Add(new KeyValuePair<string, object>(LastNameField, contact.LastName));
    fields.Add(new KeyValuePair<string, object>(PhoneNumberField, contact.PhoneNumber));
    return _ContactReplicaMetadata.FindItemMetadataByUniqueIndexedFields(fields);
}

See Also

Reference

ReplicaMetadata Class
ReplicaMetadata Members
Microsoft.Synchronization.MetadataStorage Namespace