代码拉取完成,页面将自动刷新
using System.Linq.Expressions;
public class TodoNameRemarkStatusFiltereSpecification : Specification<EleTodo>
{
private string? _name;
private string? _remark;
private TodoStatus? _status;
public TodoNameRemarkStatusFiltereSpecification(string? name, string? remark, TodoStatus? status)
{
_name = name;
_remark = remark;
_status = status;
}
public override Expression<Func<EleTodo, bool>> ToExpression()
{
Expression<Func<EleTodo, bool>> filter = PredicateBuilder.True<EleTodo>();
if (!string.IsNullOrEmpty(_name))
{
filter = filter.Compose(x => x.Name.Contains(_name), Expression.AndAlso);
}
if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_remark))
{
filter = filter.Compose(x => x.Name.Contains(_name) && (x.Remark == null ? false : x.Remark.Contains(_remark)), Expression.AndAlso);
}
if (!string.IsNullOrEmpty(_name) && !string.IsNullOrEmpty(_remark) && _status != null)
{
filter = filter.Compose(
x => x.Name.Contains(_name) && (x.Remark == null ? false : x.Remark.Contains(_remark)) && x.Status == _status,
Expression.AndAlso
);
}
return filter;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。