Hi there All.
Thank you for your Help till now !
As you know I have Decompiled plugin as I asked Here and This, I have some problem with the code.
I have solved some of them, But some other exists.
Here is the problem :
public new QuoteProduct CreatePreImageInstance() { QuoteProduct result = null; if (context.PluginExecutionContext.PreEntityImages.Contains(EntityResource.QuoteProduct) && context.PluginExecutionContext.PreEntityImages().get_Item(EntityResource.QuoteProduct) != null) { Entity val = context.PluginExecutionContext.get_PreEntityImages().get_Item(EntityResource.QuoteProduct); result = val.ToEntity<QuoteProduct>(); } return result; }
I changed this to :
public new QuoteProduct CreatePreImageInstance() { QuoteProduct result = null; if (context.PluginExecutionContext.PreEntityImages.Contains(EntityResource.QuoteProduct) && context.PluginExecutionContext.PreEntityImages.Values.FirstOrDefault(x=>x.LogicalName==EntityResource.QuoteProduct) != null) { Entity val = context.PluginExecutionContext.PreEntityImages.get_Item(EntityResource.QuoteProduct); result = val.ToEntity<QuoteProduct>(); } return result; }
The problem is this line, Did I do the right thing in changing :
context.PluginExecutionContext.PreEntityImages().get_Item(EntityResource.QuoteProduct) != null)
to :
context.PluginExecutionContext.PreEntityImages.Values.FirstOrDefault(x=>x.LogicalName==EntityResource.QuoteProduct) != null)
?
The value EntityResource.QuoteProduct in .resx file is : quotedetail.
I guess I have done the right thing.
Also please help me on this :
public class DetailEntityHelper { public Entity MergeEntity(Entity currentEntity, Entity preImageEntity) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown AttributeCollection attributes = currentEntity.Attributes; AttributeCollection attributes2 = preImageEntity.Attributes; Entity val = new Entity(currentEntity.LogicalName); foreach (KeyValuePair<string, object> item in attributes2) { if (attributes.Keys.Contains(item.Key)) { val.get_Attributes().set_Item(item.Key, attributes.get_Item(item.Key)); } else { val.get_Attributes().set_Item(item.Key, attributes2.get_Item(item.Key)); } } foreach (KeyValuePair<string, object> item2 in attributes) { if (!val.Contains(item2.Key)) { val.Attributes.Add(item2.Key, item2.Value); } } return val; }
on the line :
val.get_Attributes().set_Item(item.Key, attributes.get_Item(item.Key));
I know I should use Add instead of set_Item,
But the second parameter (attributes.get_Item(item.key) is my problem.
Any help will Appreciate
*This post is locked for comments