BPM NotSupportedException

Hi

I have the following piece of code,

var FTPN = Db.UD109
    .Where(x => x.Company == callContextClient.CurrentCompany &&
                x.Key1 == ds.PODetail[0].PartNum)
    .Select(y => y.Character01)
    .ToList();
// Store the list as a comma-separated string or "NOT FOUND" if no matches
this.FamilyToolList = FTPN.Any() 
    ? string.Join(", ", FTPN) 
    : "NOT FOUND";

If the code works as I expect. I am looking up the part number that is entered into the PODetail and returning any matching results from the UD109 table.

This may be one row or multiple rows, which is why I am returning the data as a list and converting it to a string and then store this in a variable FamilyToolList.

When I run this BPM on the PO.ChangeDetailPartNum I get the following error,

BPM runtime caught an unexpected exception of ‘NotSupportedException’ type.
See more info in the Inner Exception section of Exception Details.

Business Layer Exception

BPM runtime caught an unexpected exception of ‘NotSupportedException’ type.
See more info in the Inner Exception section of Exception Details.

Error Detail

Correlation ID: c09d0bd8-fede-41ea-9d25-ff1367c43a57
Description: BPM runtime caught an unexpected exception of ‘NotSupportedException’ type.
See more info in the Inner Exception section of Exception Details.
Program: EntityFramework.dll
Method: Translate
Table: undefined
Field: undefined

Is there a way of finding our more about this error? Or does anyone know what is causing the error?

In Entity Framework, there are certain operations you just can’t do in linq (they won’t translate to SQL). Accessing an item in a collection by index is one of them.

Instead of

x.Key1 == ds.PODetail[0].PartNum

write

var partNum = x.Key1 == ds.PODetail[0].PartNum;
...
x.Key1 == partNum
...

This way EF will not need to translate it

3 Likes

Ran into something similar the other day and had to evaluate and assign outside the linq, even though checking syntax showed no errors.

Thank you