The following code snippet is throwing a "Collection was modified; enumeration operation may not execute", specifically on the loadProperty. I can't quite figure out why, and all my workarounds haven't worked out for me. Any suggestions? I basically just want to load in all sales order details on the order.
public void ExecutePluginLogic(IServiceProvider serviceProvider)
{
// Use a 'using' statement to dispose of the service context properly
// To use a specific early bound entity replace the 'Entity' below with the appropriate class type
using (var localContext = new LocalPluginContext<Entity>(serviceProvider))
{
var activeOrders = (
from o in localContext.CrmContext.CreateQuery<SalesOrder>()
where o.StateCode.Equals(SalesOrderState.Active)
select o).Take(5).ToList();
foreach (var order in activeOrders)
{
localContext.CrmContext.LoadProperty(order, nameof(SalesOrder.order_details));
}
}
}
*This post is locked for comments

Report
All responses (
Answers (