Method Directive Error, why does the 2nd one not work?

Don’t loop on the Db object. This causes locks and all sorts of gnarly stuff.
Change your code so that the LINQ queyr runs (toList) first then loop through the result.

//Original
foreach (var County in Db.UD39.Where(County =>
                          County.Company == callContextClient.CurrentCompany &&
                          County.Key1    == callContextBpmData.ShortChar01 &&
                          County.Key2    == callContextBpmData.ShortChar02))
{
//Change to 
var listOfStuff = Db.UD39.Where(County =>
                          County.Company == callContextClient.CurrentCompany &&
                          County.Key1    == callContextBpmData.ShortChar01 &&
                          County.Key2    == callContextBpmData.ShortChar02).ToList();
foreach (var County in listOfStuff)
{
5 Likes