lundi 10 août 2020

How convert expression AndAlso to && in C# expression

I have 2 lambda expression

var exp1 = p => p.Name.ToLower().Contains("TV".ToLower());
var exp2 = p => p.ProductStatusId == 6;

and I use Expression.AndAlso to join them

var expResult= Expression.AndAlso(exp1, exp2);
ParameterExpression param = Expression.Parameter(typeof(T), "p");
var lambdaResult=Expression.Lambda<Func<T, bool>>(expResult, param);

and the lambdaResult is like below:

{p => p.Name.ToLower().Contains("TV".ToLower()) AndAlso p.ProductStatusId == 6}

now my question is how can I convert AndAlso in lambdaResult to && I want to convert the result like this:

{p => p.Name.ToLower().Contains("TV".ToLower()) && p.ProductStatusId == 6}

what should I do? thanks in advance





Aucun commentaire:

Enregistrer un commentaire