我正在为应用创建过滤器,我有两种方法访问同一窗口,第一种方法是我传递代码并获取所有记录,第二种方法是当我需要获取所有记录时< strong> code 为空或为空。搜索了很多解决方案,但没有找到
var predicate = PredicateBuilder.New<Foo>();
if (!string.IsNullOrEmpty(requestModel.code))
{
predicate = predicate.And(x => x.code == requestModel.code);
}
if (string.IsNullOrEmpty(requestModel.code))
{
//here I want to get all records from table
}
return await context.Foo
.AsExpandable()
.Where(predicate)
.ToListAsync(cancellationToken);