简体   繁体   English

如何将CRM 4类型更改为CRM 2011

[英]How to change CRM 4 Types to CRM 2011

I'm trying to convert a crm 4 Plug-in to CRM 2011. Does anybody know which are respective types in CRm 2011? 我正在尝试将crm 4插件转换为CRM2011。有人知道CRm 2011中的各自类型吗?

Customer, CrmDateTime, CrmDecimal, CrmFloat, CBoolean, CrmMoney, Owner, Picklist, Key, Status, UniqueIdentifier, CrmBoolean 客户,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;
        }

Since Dynamics CRM 2011 there is no need for custom types as a replacement for .NET types anymore. 从Dynamics CRM 2011开始,不再需要自定义类型来替代.NET类型。 You could (and have to) use the standard .NET types. 您可以(必须)使用标准的.NET类型。 See Types in the Microsoft Dynamics CRM SDK for a description of the type mapping. 有关类型映射的说明,请参见Microsoft Dynamics CRM SDK中的类型。

The existence of custom types in CRM 3 and CRM 4 ( CrmBoolean , ...) was necessary as CRM 3 was based on .NET 1 which had no Nullable Types. CRM 3和CRM 4中存在自定义类型( CrmBoolean ,...)是必要的,因为CRM 3基于没有可空类型的.NET 1。

Please see this article that documents the mapping from CRM 4 types to CRM 2011 types. 请参阅本文该文章记录了从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. 尽管不再使用大多数自定义类型,但作为查找和选择列表的属性仍然需要它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM