Case insensitivity not working for parameters

Topics: General, Help
Feb 15, 2012 at 3:51 AM


The IgnoreCase flag doesn't seem to make parameters case insensitive. Am I don't something wrong or is that the expected behaviour?

It looks to me like I would just have to add StringComparer.OrdinalIgnoreCase to the constructor of the Parameter dictionary to get this working but is there a reason this hasn't been done?



May 8, 2015 at 9:21 AM
Edited May 8, 2015 at 9:22 AM
I found that if I created a new Dictionary using the StringComparer.OrdinalIgnoreCase and then set the Parameters property for the expression to this dictionary it was case insensitive for the Parameters.

My next problem is how to make the operators case insensitive too, so we could use "OR" or "or" at the moment it is still case sensitive.

Here's my code:
        Dim Vars As New Dictionary(Of String, Object)(StringComparer.OrdinalIgnoreCase)

        For i As Integer = 1 To 5000
            Vars.Add(String.Format("My value.Val{0}", i), Math.Sqrt(i))

        ce = New Expression(Me.txExpression.Text, EvaluateOptions.IgnoreCase)
        ce.Parameters = Vars
        Dim res = ce.Evaluate
        Me.lblRes.Text = res