I would like to create this LINQ query:
Result = Result.Where(Function(Row) Convert.ToString(Row(0)).ToUpper = "TEST")
I have this query already:
Result = Result.Where(Function(Row) Convert.ToString(Row(0)) = "TEST")
with this code:
expr = Expression.Call(whereMethod, Result.AsQueryable.Expression,
Expression.Lambda(Expression.Equal(Expression.Call(convertMethod, Expression.ArrayAccess(rowParameter, Expression.Constant(index))),
Expression.Constant(constant)), rowParameter))
The convertMethod
represents Convert.ToString
, the index
has the value 0, and constant
has the value "TEST".
Now, I would like to add to this expression the ToUpper method.
I declared this:
convertMethod_toupper = GetType(String).GetMethod("ToUpper", New Type() {GetType(Object)}
)
And I found this: ToUpper in an Expression call
I should also call the ToUpper method after the Convert.ToString(Row(0))
with calling Expression.Call one more time. But how?
Thanks.
EDIT: in the meantime, I figured out, that this returns null too:
convertMethod_toupper = GetType(String).GetMethod("ToUpper", New Type() {GetType(Object)})
What is wrong with this?
If this should not be null, I think, this should be working:
expr = Expression.Call(whereMethod, Result.AsQueryable.Expression,
Expression.Lambda(Expression.Equal(Expression.Call(Expression.Call(convertMethod, Expression.ArrayAccess(rowParameter, Expression.Constant(index))), convertMethod_toupper),
Expression.Constant(constant)), rowParameter))
EDIT2: I got it.
convertMethod_toupper = GetType(String).GetMethod("ToUpper", System.Type.EmptyTypes)
and the above expression (in edit1) works.