I have a plugin that runs on a custom entity on the retrieve multiple message (post operation stage).
I am trying to add additional entities to the output entity collection (for read only purposes, the user is not going to edit any of the displayed records). The early bound classes is generated using the CrmSvcUtil from the SDK.
var retrievedResult= (EntityCollection)context.OutputParameters["BusinessEntityCollection"];
var results = new List<Entity>();
// THIS WORKS ------------------------------------
var newItem = new Entity("new_testentity");
newItem.Id = Guid.NewGuid();
newItem["new_name"] = "Test1";
results.Add(newItem);
//------------------------------------------------
// THIS IS NOT WORKING - throws exeption as shown below the code snippet
//results.Add(new new_testentity
//{
// Id = Guid.NewGuid(),
// new_name = "Test1"
//})
// Add new entities to output collection
retrievedResult.Entities.AddRange(results);
// This appears in the log, which mean the exception has not occurred yet
_trace.Trace("End of post operation...");
System.ArgumentNullException: Value cannot be null. Parameter name: value
