Question

I'm trying to add expression,which changes boolean value of current column to string value, for DataColumn:

col = new DataColumn("isDirectionIn", typeof(string),
                                     "IIF(isDirectionIn = true, 'in', 'out')");

But I always get an ArgumentException: Cannot set Expression property due to circular reference in the expression.

What should I do to avoid this exception? Thank in advance.

Was it helpful?

Solution

The error message is telling you clearly that you are referencing your Expression column in the calculation of you Expression column, thus a circular reference.

You need to do something like:

col = new DataColumn("isDirectionAsString", typeof(string),
                                     "IIF(isDirectionIn = true, 'in', 'out')");

In other words, you can't do that "in-place". You need an extra column for your "as string" value.

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top