mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-20 07:23:59 +08:00
Better solution to skip processing empty filter groups, instead of returning nothing when there's an empty filter group
This commit is contained in:
parent
5114f91526
commit
7e0a8104d3
@ -140,11 +140,6 @@ namespace Orchard.Projections.Services {
|
||||
|
||||
var contentItems = new List<ContentItem>();
|
||||
|
||||
// If there are no filters, return the empty list of content items instead of returning all content items.
|
||||
if (queryRecord.FilterGroups.SelectMany(group => group.Filters).Count() == 0) {
|
||||
return contentItems;
|
||||
}
|
||||
|
||||
// prepares tokens
|
||||
Dictionary<string, object> tokens = new Dictionary<string, object>();
|
||||
if (part != null) {
|
||||
@ -209,8 +204,8 @@ namespace Orchard.Projections.Services {
|
||||
|
||||
var version = queryRecord.VersionScope.ToVersionOptions();
|
||||
|
||||
// pre-executing all groups
|
||||
foreach (var group in queryRecord.FilterGroups) {
|
||||
// Iterate over each filter group, but ignore empty ones, because they'd cause all content items to be returned.
|
||||
foreach (var group in queryRecord.FilterGroups.Where(group => group.Filters.Count > 0)) {
|
||||
var contentQuery = _contentManager.HqlQuery().ForVersion(version);
|
||||
|
||||
// iterate over each filter to apply the alterations to the query object
|
||||
|
Loading…
Reference in New Issue
Block a user