SqlMetadataStore.InitializeReplicaMetadata Method

Creates and initializes metadata for a replica in the metadata store, and returns a replica metadata object that is used to access the replica metadata.

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

Syntax

'Declaration
Public Overrides Function InitializeReplicaMetadata ( _
    idFormats As SyncIdFormatGroup, _
    replicaId As SyncId, _
    customItemFieldSchemas As IEnumerable(Of FieldSchema), _
    customIndexedFieldSchemas As IEnumerable(Of IndexSchema) _
) As ReplicaMetadata
'Usage
Dim instance As SqlMetadataStore
Dim idFormats As SyncIdFormatGroup
Dim replicaId As SyncId
Dim customItemFieldSchemas As IEnumerable(Of FieldSchema)
Dim customIndexedFieldSchemas As IEnumerable(Of IndexSchema)
Dim returnValue As ReplicaMetadata

returnValue = instance.InitializeReplicaMetadata(idFormats, replicaId, customItemFieldSchemas, customIndexedFieldSchemas)
public override ReplicaMetadata InitializeReplicaMetadata (
    SyncIdFormatGroup idFormats,
    SyncId replicaId,
    IEnumerable<FieldSchema> customItemFieldSchemas,
    IEnumerable<IndexSchema> customIndexedFieldSchemas
)
public:
virtual ReplicaMetadata^ InitializeReplicaMetadata (
    SyncIdFormatGroup^ idFormats, 
    SyncId^ replicaId, 
    IEnumerable<FieldSchema^>^ customItemFieldSchemas, 
    IEnumerable<IndexSchema^>^ customIndexedFieldSchemas
) override
public ReplicaMetadata InitializeReplicaMetadata (
    SyncIdFormatGroup idFormats, 
    SyncId replicaId, 
    IEnumerable<FieldSchema> customItemFieldSchemas, 
    IEnumerable<IndexSchema> customIndexedFieldSchemas
)
public override function InitializeReplicaMetadata (
    idFormats : SyncIdFormatGroup, 
    replicaId : SyncId, 
    customItemFieldSchemas : IEnumerable<FieldSchema>, 
    customIndexedFieldSchemas : IEnumerable<IndexSchema>
) : ReplicaMetadata

Parameters

  • idFormats
    The ID format schema for the provider.
  • replicaId
    The replica ID that is associated with this metadata.
  • customItemFieldSchemas
    The collection of schema information for the custom metadata fields for each metadata item. Can be a null reference (Nothing in Visual Basic) when there are no custom metadata fields.
  • customIndexedFieldSchemas
    The list of index schemas that can be used to more efficiently find items in the metadata store. Can be a null reference (Nothing in Visual Basic) when there are no custom indexes.

Return Value

The replica metadata object that is used to access the replica metadata in the metadata store.

Exceptions

Exception type Condition

ObjectDisposedException

This object has been disposed or was not initialized correctly.

ArgumentNullException

idFormats or replicaId is a null reference (Nothing in Visual Basic).

ArgumentException

Any of the custom field names in customItemFieldSchemas is 0 length.

NullReferenceException

Any of the custom field names in customItemFieldSchemas is a null reference (Nothing in Visual Basic).

MetadataFieldNotFoundException

A field listed in customIndexedFieldSchemas does not exist in customItemFieldSchemas.

SyncIdFormatMismatchException

The format of replicaId does not match the format that is specified in idFormats.

ArgumentOutOfRangeException

The length of an ID specified by idFormats is more than 8000 bytes.

InvalidOperationException

A metadata store has not been opened or created.

ReplicaMetadataAlreadyExistsException

Replica metadata already exists in the metadata store for the specified replicaId.

Remarks

This method is used to create a new set of replica metadata in the metadata store. To access existing replica metadata in a metadata store, use GetReplicaMetadata.

This method returns the implementation of the ReplicaMetadata abstract class that is provided by Metadata Storage Services. This abstract class can be used to access replica metadata that is stored in the Sync Framework database file.

A set of custom fields can be defined for item metadata by using customItemFieldSchemas. Each field consists of a unique string name and a value. These fields can store any additional metadata about an item that is not otherwise supported by the default set of item metadata. The fields can be accessed through various methods on ItemMetadata, such as ItemMetadata.GetByteField or Microsoft.Synchronization.MetadataStorage.ItemMetadata.SetCustomField.

A set of index schemas can be defined by using customIndexedFieldSchemas so that sets of custom fields can be used as indexes to efficiently find items in the metadata store. An index schema can be defined as unique to ensure that the index defines one item. Each field that is contained in an index schema must also exist in the custom field schema that is defined for the replica. Index fields can be used in methods such as ReplicaMetadata.FindItemMetadataByIndexedField and ReplicaMetadata.FindItemMetadataByUniqueIndexedFields.

See Also

Reference

SqlMetadataStore Class
SqlMetadataStore Members
Microsoft.Synchronization.MetadataStorage Namespace