【发布时间】:2022-01-20 16:58:51
【问题描述】:
我有以下问题
var predicate = PredicateBuilder.True<SearchModel>();
predicate = predicate.And(x => (templateIDs.Contains(x.TemplateId))); // To match certain templates only
var products = searchContext.GetQueryable()
.Where(predicate)
.OrderBy(i => i.Title) //will order the items by display
.Take(pageSize); //pageSize is passed through and is an integer
.GetResults();
我从来没有得到按字母顺序排列的结果。
但是,如果我执行以下操作,则结果排序正确。
var fullResults = searchResults.ToList().OrderBy(x=>x.Title).Take(pageSize); //pageSize is passed through and is an integer
有人知道为什么吗?
如果我以第二种方式 (.ToList().OrderBy().Take().) 执行此操作,是否会对性能产生影响,因为我相信在从中获取结果后会对结果进行排序和分页索尔?
【问题讨论】: