Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Target always an Entity or can it be EntityReference?

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?

like image 522
Konrad Viltersten Avatar asked Dec 27 '22 07:12

Konrad Viltersten


1 Answers

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.

like image 174
Guido Preite Avatar answered Jan 06 '23 01:01

Guido Preite