Value passed in variable creating error in linq statement

I am trying to filter an enumerable by reference. I am using a string variable called ‘jobitem’.

My workflow throws an exception when using the where statement in the code.

I went to debug in the immediate window.

The statement I am using is this:

InProgressItems.Where(function(i) i.Reference.Equals(jobitem))

Currently jobitem is set to string value “Process4”

When I use the same statement, but hardcode the string value in, there is no issue.

The following screenshot shows the testing in immediate panel:

What is the exception?

It is shown in the last line of the immediate window. It is a !<ObjectDisposedException>

I found a fix however, and it was calling .ToList() on the source of the jobitem, which was an iterator returned from a previous distinct statement.

I’m glad you found a workaround. Would you say that there is still something that we could improve in the Studio itself?