首页 > 解决方案 > 如何获取任何 crm 实体属性的 edm 数据类型(odata 类型)

问题描述

GET [Organization URI]/api/data/v9.0//EntityDefinitions(LogicalName=account)/Attributes?$select=LogicalName,AttributeType,AttributeOf

此 api 为我提供 Picklist、Money 等数据类型(crm 数据类型),我正在寻找的是 edm 数据类型,如 Edm.Int32(picklist)、Edm.Decimal(Money)

标签: dynamics-crmolingo

解决方案


据我所知,元数据缺少对本机 .NET 类型的任何引用。

此表提供映射。

这里还有一个截图: 类型映射

这是我在代码中映射它们的一种方式:

var dictionary = new Dictionary<AttributeTypeCode, Type>
{
    {AttributeTypeCode.Integer, typeof(int) },
    {AttributeTypeCode.BigInt, typeof(long) },
    {AttributeTypeCode.Decimal, typeof(decimal) },
    {AttributeTypeCode.Double, typeof(double) },
    {AttributeTypeCode.DateTime, typeof(DateTime) },
    {AttributeTypeCode.Money, typeof(decimal) },
};

推荐阅读