本文整理汇总了C#中IEdmEntityTypeReference.Key方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityTypeReference.Key方法的具体用法?C# IEdmEntityTypeReference.Key怎么用?C# IEdmEntityTypeReference.Key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmEntityTypeReference
的用法示例。
在下文中一共展示了IEdmEntityTypeReference.Key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CovertEntityId
internal static object CovertEntityId(object source, ODataEntry entry, IEdmEntityTypeReference entityTypeReference, ODataDeserializerContext readContext)
{
Contract.Assert(entry != null);
Contract.Assert(source != null);
if (entry.Id == null || entry.Properties.Any())
{
return source;
}
HttpRequestMessage request = readContext.Request;
IEdmModel edmModel = readContext.Model;
DefaultODataPathHandler pathHandler = new DefaultODataPathHandler();
string serviceRoot = GetServiceRoot(request);
IDictionary<string, string> keyValues = GetKeys(pathHandler, edmModel, serviceRoot, entry.Id);
IList<IEdmStructuralProperty> keys = entityTypeReference.Key().ToList();
if (keys.Count == 1 && keyValues.Count == 1)
{
object propertyValue = ODataUriUtils.ConvertFromUriLiteral(keyValues.First().Value, ODataVersion.V4, edmModel, keys[0].Type);
DeserializationHelpers.SetDeclaredProperty(source, EdmTypeKind.Primitive, keys[0].Name, propertyValue, keys[0], readContext);
return source;
}
foreach (IEdmStructuralProperty key in keys)
{
string value;
if (keyValues.TryGetValue(key.Name, out value))
{
object propertyValue = ODataUriUtils.ConvertFromUriLiteral(value, ODataVersion.V4, edmModel, key.Type);
DeserializationHelpers.SetDeclaredProperty(source, EdmTypeKind.Primitive, key.Name, propertyValue, key, readContext);
}
}
return source;
}