jeudi 16 septembre 2021

How to apply string comparision invariant to expression call in c# reflection?

I ahve a method like following and using entity framework search.

public static Expression Equals(Expression left, Expression right)
{
    var methodInfo = typeof(string).GetMethod("Equals", new[] { typeof(string) }) ?? throw new InvalidOperationException();

    var expr = Expression.Call(left, methodInfo, right);

    return expr;
}

But I want to add StringComparer.InvariantCulture in this expression call.

How can I do this?





Aucun commentaire:

Enregistrer un commentaire