Hi,
my create plugin works totaly fine and i used stronly typed classes to my the entity class.
After that i wrote plugin which only handles updates in the pre-validation stage. During this stage only PreImage is available. The plugin needs to do some calculations and for that i need always the complete updated record. This not possible because old
values and not changed values are in the PreImage and the changed ones in the Target.
Is there a better way to merge them and create then a stronly typed instance ?
Currently i am doing a hack(see code below) and do a manual merge of all the Attributes in Target and hang them into the attributes array of PreImage and create then a stronly typed instance/class of it.
Don't know if this breaks anything later. The other way would be to write a little helper which checks first if the attribute is in Target and if not it takes it from PreImage so i always get the updated vales or the not changed ones, but i can not use strongly
typed classes anymore and no intelli sense.
Any ideas ?
Kind Regards
Markus
CrmStronglyTypedClasses.prg_abrechnungsposition dienstleistungposition = ((Entity)localContext.PluginExecutionContext.InputParameters["Target"]).ToEntity<CrmStronglyTypedClasses.prg_abrechnungsposition>();
Entity EntityPreImage = null;
CrmStronglyTypedClasses.prg_abrechnungsposition preImageDienstleistungposition = null;
if (localContext.PluginExecutionContext.PreEntityImages.Contains("PreImage") && localContext.PluginExecutionContext.PreEntityImages["PreImage"] is Entity)
{
EntityPreImage = (Entity)localContext.PluginExecutionContext.PreEntityImages["PreImage"];
foreach (KeyValuePair<string, object> value in ((Entity)localContext.PluginExecutionContext.InputParameters["Target"]).Attributes)
{
EntityPreImage.Attributes[value.Key] = value.Value;
}
preImageDienstleistungposition = ((Entity)localContext.PluginExecutionContext.PreEntityImages["PreImage"]).ToEntity<CrmStronglyTypedClasses.prg_abrechnungsposition>();
}