我正在与一位同事就在插件或工作流程中使用 Web 服务进行辩论
他说使用动态实体是微软建议的最佳实践,因为网络服务需要身份验证。
我认为使用 wsdl 和强类型实体更干净且不易出错,并且身份验证延迟可以忽略不计
此外,我们计划更新到 CRM 2011
那么,我们谁是对的?
最佳答案
强类型实体和动态实体都使用 Web 服务,两者都需要身份验证,因此没有真正的区别。
在升级到 Crm 2011 方面,2011 年 Web 服务发生了变化,因此如果您想重新编码也可以,但两者都必须重新编码。或者您可以继续使用 Crm 4 Web 服务而不重新编码。所以同样没有真正的区别。
我找不到 Microsoft 的任何信息表明他们更喜欢动态实体。在 Best Practices for Developing with Microsoft Dynamics CRM 2011他们实际上说根据您的情况使用两者。
Use the Entity class when your code must work on entities and attributes that are not known at the time the code is written. However, this flexibility has a disadvantage because you cannot verify entity and attribute names at compile time. If your entities are already defined at code time, you should use the early-bound types that you can generate by using the CrmSvcUtil tool. For more information, see Use the Early Bound Entity Classes in Code.
我认为这主要取决于风格和偏好(没有人是正确的) - 我个人更喜欢动态实体。
强类型 - 优点:
- 智能感知
- 设计\编译时验证
- 您不必检查 Crm 中的所有实体、字段和关系名称
- 编译后的可执行文件包含调用类型的属性、方法和事件所需的代码
强类型 - 缺点:
- 您必须生成 WSDL(并在每次 Crm 更改时不断重新生成)
- 我上次检查时生成的类未通过代码分析
- 这可能有点“严厉”,例如使用动态实体创建新记录通常只需几行。必须生成数百个强类型类来编写几行代码似乎有些过大了。
关于.net - 在 Microsoft CRM 4.0 中使用 Web 服务与使用动态实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11775410/