我正在为应用程序创建过滤器,并且我对同一窗口有两种方法,第一种方法是当我传递代码并使用它获取所有记录时,第二种方法是当我需要在代码为 Null 或 Empty 时获取所有记录时。搜索了很多解决方案,但没有找到任何解决方案
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);