I want to create a lambda expression dynamically for this:
(o => o.Year == year && o.CityCode == cityCode && o.Status == status)
and I write this:
var body = Expression.AndAlso(
Expression.Equal(
Expression.PropertyOrField(param, "Year"),
Expression.Constant(year)
),
Expression.Equal(
Expression.PropertyOrField(param, "CityCode"),
Expression.Constant(cityCode)
)
,
Expression.Equal(
Expression.PropertyOrField(param, "Status"),
Expression.Constant(status)
)
);
but for this chunk of code:
Expression.Equal(
Expression.PropertyOrField(param, "Status"),
Expression.Constant(status)
)
I got an error:
Cannot convert from 'System.Linq.Expressions.BinaryExpression' to 'System.Reflection.MethodInfo'
How I can add 3 conditions to a lambda expression?