Metodo IModelKeyReference2::SetKey (dbgmodel.h)
Il metodo SetKey in un riferimento chiave si comporta come metodo SetKey in IModelObject . Assegna il valore della chiave. Se la chiave originale era una funzione di accesso di proprietà, questa sostituirà la funzione di accesso alla proprietà. Non chiamerà il metodo SetValue nella funzione di accesso della proprietà.
Sintassi
HRESULT SetKey(
IModelObject *object,
IKeyStore *metadata
);
Parametri
object
Valore da assegnare alla chiave.
metadata
Metadati facoltativi da associare alla chiave.
Valore restituito
Questo metodo restituisce HRESULT che indica l'esito positivo o l'errore.
Commenti
Codice di esempio
ComPtr<IDataModelManager> spManager; /* get the data model manager */
ComPtr<IModelObject> spObject; /* get an object */
ComPtr<IModelKeyReference> spKeyRef;
if (SUCCEEDED(spObject->GetKeyReference(L"Id", &spKeyRef, nullptr)))
{
VARIANT vtValue;
vtValue.vt = VT_UI8;
vtValue.ullVal = 42;
ComPtr<IModelObject> sp42;
if (SUCCEEDED(spManager->CreateIntrinsicObject(ObjectIntrinsic, &vtValue, &sp42)))
{
if (SUCCEEDED(spKeyRef->SetKey(sp42.Get(), nullptr)))
{
// The "Id" key has been overwritten with the value 42.
// If the "Id" key originally was a property accessor, it isn't anymore.
// This would not have called SetValue() on the property accessor.
// It replaced the property accessor with a static "42".
}
}
}
Requisiti
Requisito | Valore |
---|---|
Intestazione | dbgmodel.h |
Vedi anche
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per