我有以下代码:
public override IList<IEntity> GetByEmail(IList<string> emailAddresses)
{
//build lambda expression
var result = All.Where(BuildEmailFilterExpression<T, string>(
propertyInfo.Name, x => emailAddresses.Contains(x)));
return result.Cast<IEntity>().ToList();
}
private static Func<T, bool> BuildEmailFilterExpression<TSource, TProp>(
string propertyName, Expression<Func<TProp, bool>> predicate)
{
ParameterExpression paramExpr = Expression.Parameter(typeof(TSource));
MemberExpression propExpr = Expression.Property(paramExpr, propertyName);
return Expression.Lambda<Func<T, bool>>(Expression.Invoke(predicate, propExpr),
paramExpr).Compile();
}
All函数返回实例,Person属性Email需要不区分大小写。 如何在不使用IndexOf的情况下使此表达式不区分大小写ToUpper或ToLower。