MetaTable.GetPrimaryKeyDictionary(Object) 方法

定义

为指定行检索主键名称和值的字典。

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

一个行。

返回

IDictionary<String,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   

适用于