Code Review Needed

Thank! It was

LINQ to Entities does not recognize the method ‘System.String get_Item(System.String)’ method, and this method cannot be translated into a store expression.

1 Like

Interesting. It is going to take me a while to digest. ChatGPT also recommended StringBuilder.

Ohhh it doesn’t like your dictionary lookup within the linq query.

If you replace

if (!string.IsNullOrEmpty(pkColl["Fit"]))
{
  udPartDesc = Db.UDCodes.Select(ud => ud.CodeTypeID == "Fit" && ud.CodeID == pkColl["Fit"]).ToString();
  partDesc = udPartDesc;
}

with

if (!string.IsNullOrEmpty(pkColl["Fit"]))
{
  string dictValue = pcColl["Fit"];
  udPartDesc = Db.UDCodes.Select(ud => ud.CodeTypeID == "Fit" && ud.CodeID == dictValue).ToString();
  partDesc = udPartDesc;
}

That should solve your error.

1 Like

That “LINQ to Entities” always catches me off guard.

2 Likes