Condividi tramite


Metodo IModelKeyReference::SetKeyValue (dbgmodel.h)

Il metodo SetKeyValue in un riferimento di chiave si comporta come il metodo SetKeyValue su IModelObject. Assegnerà il valore della chiave. Se la chiave originale è una funzione di accesso alla proprietà, verrà chiamato il metodo SetValue sottostante nella funzione di accesso della proprietà anziché sostituire la funzione di accesso alla proprietà stessa.

Sintassi

HRESULT SetKeyValue(
  IModelObject *object
);

Parametri

object

Valore da assegnare alla chiave.

Valore restituito

Questo metodo restituisce HRESULT che indica l'esito positivo o negativo.

Osservazioni

esempio di codice

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->SetKeyValue(sp42.Get())))
        {
            // The value of the "Id" key is now 42.  If the "Id" key originally 
            // was a property accessor, this successfully called
            // the SetValue() method on the property accessor.  In such a case, 
            // the property accessor was not replaced with the static 42, 
            // it was called to set the value 42.
        }
    }
}

Fabbisogno

Requisito Valore
intestazione dbgmodel.h

Vedere anche

'interfaccia IModelKeyReference