Is Target always an Entity or can it be EntityReference?

谁说我不能喝 提交于 2019-12-12 12:19:55

问题


I discovered that in some of my code I have the following syntax guarding the plugin from FUBARing. I can't for the love of god not remember why I put the disjuction conditional for EntityReference.

Is Context.InputParameters["Target"] every EntityReference?

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

Is it ever anything other than Entity?


回答1:


Target can be also an EntityReference, from MSDN:

Note that not all requests contain a Target property that is of type Entity, so you do have to look at each individual request or response. For example, DeleteRequest does have a Target property but its type is EntityReference.

Understand the Data Context Passed to a Plug-In

So depending on the logic of your plugin you may need to check the property type also for EntityReference.



来源:https://stackoverflow.com/questions/15613026/is-target-always-an-entity-or-can-it-be-entityreference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!