Creating a plugin for virtual entity, while trying to parse an EntityCollection to PluginExecutionContext in Microsoft.Xrm.Sdk it fails with message
Error
"message":"OutputParameters must contain a property called 'BusinessEntityCollection' of type Microsoft.Xrm.Sdk.EntityCollection for SDK message RetrieveMultiple",
Code is something like
string data = await GetData(localcontext);
var desrlzdData = JsonConvert.DeserializeObject<CustomEntity[]>(data);
EntityCollection collection = new EntityCollection();
foreach (var d in desrlzdData)
{
collection.Entities.Add(mapper(d));
}
// Add result to output parameters
localcontext.PluginExecutionContext.OutputParameters["BusinessEntityCollection"] = collection;
2
Answers
The problem was with async code, I was not doing await at one of the place. So The BusinessEntityCollection was not getting populated but the error message is bit misleading.
Modify the last time in this: