IModelKeyReference::GetKeyValue 方法 (dbgmodel.h)
索引鍵參考上的 GetKeyValue 方法會如同 IModelObject 上 GetKeyValue 方法一樣。 它會傳回基礎索引鍵的值,以及與索引鍵相關聯的任何元數據。 如果索引鍵的值恰好是屬性存取子,這會自動在屬性存取子上呼叫基礎 GetValue 方法。
語法
HRESULT GetKeyValue(
_COM_Errorptr_opt_ IModelObject **object,
IKeyStore **metadata
);
參數
object
此處會傳回索引鍵的值。 請注意,當失敗時,可能會在這裡傳回擴充的錯誤資訊。
metadata
此處會傳回與金鑰相關聯的選擇性元數據。
傳回值
此方法會傳回表示成功或失敗的 HRESULT。
言論
程式代碼範例
ComPtr<IModelObject> spObject; /* get an object */
ComPtr<IModelKeyReference> spKeyRef;
if (SUCCEEDED(spObject->GetKeyReference(L"Id", &spKeyRef, nullptr)))
{
ComPtr<IModelObject> spId;
if (SUCCEEDED(spKeyRef->GetKeyValue(&spId, nullptr)))
{
// spId contains the value of the "Id" key
}
}
要求
要求 | 價值 |
---|---|
標頭 | dbgmodel.h |