Yes, this is caused by restrictions due to EF Core. I have it in several BPMs, and it appears to be (I’ve only successfully squashed it in one BPM so far) due to nested foreach’s.
In the skeleton below, I have the relevant structure from one of my DD BPMs. To fix the error, I only had to add “.ToList()” after the SELECT of the inner foreach statement.
foreach (var ttTableRow in
(from TR in ttOrderHed
where (TR.RowMod != "")
select new
{
TR.RowMod,
TR.Company,
TR.OrderNum,
TR.OrderDate,
TR.CustNum,
TR.PONum
}
)
)
//
//
// ITERATE THROUGH EACH ROW OF THE SELECT RESULTS
//
//
{
//
// GET NEXT RESULT ROW
//
var ttThisRow = ttTableRow;
var vThisRowCompany = ttThisRow.Company;
var vThisRowOrderNum = ttThisRow.OrderNum;
var vThisRowCustNum = ttThisRow.CustNum;
//
// ITERATE THROUGH EACH ORDER LINE and RELEASE
//
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
foreach (var ttFullRow in
(from OD in Db.OrderDtl.With(LockHint.NoLock)
join OR in Db.OrderRel.With(LockHint.NoLock) on
new {OD.Company, OD.OrderNum, OD.OrderLine} equals
new {OR.Company, OR.OrderNum, OR.OrderLine}
where (OD.Company == vThisRowCompany)
where (OD.OrderNum == vThisRowOrderNum)
select new
{
ttThisRow.RowMod,
ttThisRow.Company,
ttThisRow.OrderNum,
ODOrderLine = OD.OrderLine,
ODPartNum = OD.PartNum,
ODRevisionNum = OD.RevisionNum,
ODLineDesc = OD.LineDesc,
ODUnitPrice = OD.UnitPrice,
OROrderRelNum = OR.OrderRelNum,
ORShipToNum = OR.ShipToNum
}
).ToList() // <------------ ADDED .ToList() HERE
)
{
// DO INNER FOREACH STUFF
}
} // END OF OUTER FOREACH
Note that my actual code (about 700 lines) has many more “(from xyz in …)” statements further above and below this code chunk, but it seems that for this error, it is the nested foreach’s that it doesn’t like.
I’m sure there are other code permutations that might generate this error, but hopefully, this is a useful starting point of what to check.
EDIT: Here is the comment that helped me understand what was causing it.
EDIT2: Repeated this fix for two more BPMs having this error, and it resolved the issue in both cases.