2

我正在尝试将 crm 4 插件转换为 CRM 2011。有人知道 CRM 2011 中的相应类型吗?

客户、CrmDateTime、CrmDecimal、CrmFloat、CBool​​ean、CrmMoney、所有者、选项列表、键、状态、UniqueIdentifier、CrmBoolean

public static object GetAttributeValue(this Entity target, string attributeLogicalName)
        {
            object value;
            if (target.Attributes.Contains(attributeLogicalName))
            {
                value = target.Attributes[attributeLogicalName];
                if ((value is Boolean) || (value is string))
                    return value;
                else if (value is Customer)
                    return ((Customer)value).Value;
                else if (value is CrmDateTime)
                    return ((CrmDateTime)value).UserTime;
                else if (value is CrmDecimal)
                    return ((CrmDecimal)value).Value;
                else if (value is CrmFloat)
                    return ((CrmFloat)value).Value;
                else if (value is CrmNumber)
                    return ((CrmNumber)value).Value;
                else if (value is CBoolean)
                    return ((CrmBoolean)value).Value;
                else if (value is Lookup)
                    return ((Lookup)value).Value;
                else if (value is CrmMoney)
                    return ((CrmMoney)value).Value;
                else if (value is Owner)
                    return ((Owner)value).Value;
                else if (value is Picklist)
                    return ((Picklist)value).Value;
                else if (value is Key)
                    return ((Key)value).Value;
                else if (value is Status)
                    return ((Status)value).Value;
                else if (value is UniqueIdentifier)
                    return ((UniqueIdentifier)value).Value;
                else if (value is CrmBoolean)
                    return ((CrmBoolean)value).Value;
                return null;
            }
            else
                return null;
        }
4

2 回答 2

5

由于 Dynamics CRM 2011 不再需要自定义类型来替代 .NET 类型。您可以(并且必须)使用标准的 .NET 类型。有关类型映射的说明,请参阅Microsoft Dynamics CRM SDK中的类型。

CRM 3 和 CRM 4 ( CrmBoolean, ...) 中存在自定义类型是必要的,因为 CRM 3 基于没有 Nullable 类型的 .NET 1。

于 2013-01-14T10:16:15.733 回答
0

请参阅这篇记录从 CRM 4 类型到 CRM 2011 类型的映射的文章。

It is not entirely true that custom types are no longer required. While most custom types are no longer used they are still required for attributes that are lookups and picklists.

于 2013-01-15T21:12:18.927 回答