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