ReplicaMetadata.CreateItemMetadata Method
When overridden in a derived class, creates a new item metadata object that can be used to add a new item metadata entry to the metadata store.
Namespace: Microsoft.Synchronization.MetadataStorage
Assembly: Microsoft.Synchronization.MetadataStorage (in microsoft.synchronization.metadatastorage.dll)
Syntax
'Declaration
Public MustOverride Function CreateItemMetadata ( _
globalId As SyncId, _
creationVersion As SyncVersion _
) As ItemMetadata
'Usage
Dim instance As ReplicaMetadata
Dim globalId As SyncId
Dim creationVersion As SyncVersion
Dim returnValue As ItemMetadata
returnValue = instance.CreateItemMetadata(globalId, creationVersion)
public abstract ItemMetadata CreateItemMetadata (
SyncId globalId,
SyncVersion creationVersion
)
public:
virtual ItemMetadata^ CreateItemMetadata (
SyncId^ globalId,
SyncVersion^ creationVersion
) abstract
public abstract ItemMetadata CreateItemMetadata (
SyncId globalId,
SyncVersion creationVersion
)
public abstract function CreateItemMetadata (
globalId : SyncId,
creationVersion : SyncVersion
) : ItemMetadata
Parameters
- globalId
The global ID of the item to create. The global ID must be unique.
- creationVersion
The creation version to associate with this item.
Return Value
The newly created item metadata object.
Exceptions
Exception type | Condition |
---|---|
The object has been disposed or was not initialized correctly. |
|
globalId or creationVersion is a null reference (Nothing in Visual Basic). |
|
There is not enough memory to create the item metadata. |
|
The format of globalId does not match the format that was specified when the replica metadata was initialized. |
Remarks
This item metadata is not saved to the metadata store until SaveItemMetadata is called.
Example
The following example creates metadata for an item, sets the change unit version for each change unit in the item, and sets the custom field values for the index fields of the item.
private ItemMetadata CreateContactMetadata(Contact contact, SyncId itemId, SyncVersion creationVersion,
SyncVersion changeVersion)
{
// Create the item by using the metadata storage service.
ItemMetadata itemMeta = _ContactReplicaMetadata.CreateItemMetadata(itemId, creationVersion);
// Set the version information for each change unit.
itemMeta.SetChangeUnitVersion(new SyncId((byte)Contact.ChangeUnitFields.NameCU), changeVersion);
itemMeta.SetChangeUnitVersion(new SyncId((byte)Contact.ChangeUnitFields.PhoneCU), changeVersion);
itemMeta.SetChangeUnitVersion(new SyncId((byte)Contact.ChangeUnitFields.AddressCU), changeVersion);
itemMeta.SetChangeUnitVersion(new SyncId((byte)Contact.ChangeUnitFields.BirthdateCU), changeVersion);
// A unique index is defined for the combination of first name, last name, and phone number in order
// to map between the item ID and the contact.
// Set the field values for the index fields.
itemMeta.SetCustomField(FirstNameField, contact.FirstName);
itemMeta.SetCustomField(LastNameField, contact.LastName);
itemMeta.SetCustomField(PhoneNumberField, contact.PhoneNumber);
return itemMeta;
}
See Also
Reference
ReplicaMetadata Class
ReplicaMetadata Members
Microsoft.Synchronization.MetadataStorage Namespace