【问题标题】:Is Target always an Entity or can it be EntityReference?Target 始终是一个实体还是可以是 EntityReference?
【发布时间】:2013-03-14 19:54:00
【问题描述】:

我发现在我的一些代码中,我有以下语法来保护插件免受 FUBARing 的影响。看在上帝的份上,我不记得为什么我将析取条件设置为 EntityReference

Context.InputParameters["Target"] 是每一个 EntityReference 吗?

bool goodToGo 
  = Context.InputParameters.Contains("Target")
    && Context.PrimaryEntityName == "email";
    && (
      Context.InputParameters["Target"] is Entity
      || Context.InputParameters["Target"] is EntityReference);

除了实体之外,是否有任何东西

【问题讨论】:

  • 还有一些其他的东西也可以——我确实在某个地方有一个列表。现在如果我能记得在哪里......

标签: c# plugins dynamics-crm-2011


【解决方案1】:

Target 也可以是 EntityReference,来自 MSDN:

请注意,并非所有请求都包含实体类型的 Target 属性,因此您必须查看每个单独的请求或响应。例如,DeleteRequest 确实有一个 Target 属性,但它的类型是 EntityReference。

Understand the Data Context Passed to a Plug-In

因此,根据插件的逻辑,您可能还需要检查 EntityReference 的属性类型。

【讨论】:

  • 当然... 现在我记得 - 我在删除实体时遇到了问题。很好的答案:+1。
猜你喜欢
  • 2015-11-03
  • 2012-02-20
  • 2020-06-15
  • 1970-01-01
  • 1970-01-01
  • 2014-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多