MetaTable.GetPrimaryKeyDictionary(Object) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取指定資料列之主索引鍵名稱及值的字典。
public:
virtual System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ GetPrimaryKeyDictionary(System::Object ^ row);
public System.Collections.Generic.IDictionary<string,object> GetPrimaryKeyDictionary (object row);
abstract member GetPrimaryKeyDictionary : obj -> System.Collections.Generic.IDictionary<string, obj>
override this.GetPrimaryKeyDictionary : obj -> System.Collections.Generic.IDictionary<string, obj>
Public Function GetPrimaryKeyDictionary (row As Object) As IDictionary(Of String, Object)
參數
- row
- Object
資料列。
傳回
主索引鍵名稱及值的字典。
範例
下列範例示範如何建立主鍵字典。
private RouteValueDictionary GetRouteValues(MetaTable table, object row) {
RouteValueDictionary routeValues = GetRouteValues();
foreach (var pk in table.GetPrimaryKeyDictionary(row)) {
routeValues[pk.Key] = pk.Value;
}
return routeValues;
}
Private Function GetRouteValues(ByVal table As MetaTable, _
ByVal row As Object) As RouteValueDictionary
Dim routeValues As RouteValueDictionary = GetRouteValues()
For Each pk In table.GetPrimaryKeyDictionary(row)
routeValues(pk.Key) = pk.Value
Next
Return routeValues
End Function