Pregunta

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.

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top