@@ -128,7 +128,7 @@ public int GetCount(int queryId, ContentPart part)
128128 var queryRecord = _queryRepository . Get ( queryId ) ?? throw new ArgumentException ( "queryId" ) ;
129129
130130 // Prepare tokens.
131- Dictionary < string , object > tokens = new Dictionary < string , object > ( ) ;
131+ var tokens = new Dictionary < string , object > ( ) ;
132132 if ( part != null )
133133 {
134134 tokens . Add ( "Content" , part . ContentItem ) ;
@@ -151,17 +151,11 @@ public IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, i
151151 {
152152 var availableSortCriteria = DescribeSortCriteria ( ) . ToList ( ) ;
153153
154- var queryRecord = _queryRepository . Get ( queryId ) ;
155-
156- if ( queryRecord == null )
157- {
158- throw new ArgumentException ( "queryId" ) ;
159- }
160-
154+ var queryRecord = _queryRepository . Get ( queryId ) ?? throw new ArgumentException ( "queryId" ) ;
161155 var contentItems = new List < ContentItem > ( ) ;
162156
163157 // Prepare tokens.
164- Dictionary < string , object > tokens = new Dictionary < string , object > ( ) ;
158+ var tokens = new Dictionary < string , object > ( ) ;
165159 if ( part != null )
166160 {
167161 tokens . Add ( "Content" , part . ContentItem ) ;
@@ -186,7 +180,8 @@ public IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, i
186180 return Enumerable . Empty < ContentItem > ( ) ;
187181 }
188182
189- var groupQuery = _contentManager . HqlQuery ( ) . Where ( alias => alias . Named ( "ci" ) , x => x . InG ( "Id" , ids ) ) ;
183+ var version = queryRecord . VersionScope . ToVersionOptions ( ) ;
184+ var groupQuery = _contentManager . HqlQuery ( ) . ForVersion ( version ) . Where ( alias => alias . Named ( "ci" ) , x => x . InG ( "Id" , ids ) ) ;
190185
191186 // Iterate over each sort criteria to apply the alterations to the query object.
192187 foreach ( var sortCriterion in queryRecord . SortCriteria . OrderBy ( s => s . Position ) )
@@ -200,8 +195,8 @@ public IEnumerable<ContentItem> GetContentItems(int queryId, ContentPart part, i
200195 Tokens = tokens
201196 } ;
202197
203- string category = sortCriterion . Category ;
204- string type = sortCriterion . Type ;
198+ var category = sortCriterion . Category ;
199+ var type = sortCriterion . Type ;
205200
206201 // Find specific sort criterion.
207202 var descriptor = availableSortCriteria
@@ -255,8 +250,8 @@ public IEnumerable<IHqlQuery> GetContentQueries(
255250 Tokens = tokens
256251 } ;
257252
258- string category = filter . Category ;
259- string type = filter . Type ;
253+ var category = filter . Category ;
254+ var type = filter . Type ;
260255
261256 // Find specific filter.
262257 var descriptor = availableFilters
@@ -287,8 +282,8 @@ public IEnumerable<IHqlQuery> GetContentQueries(
287282 Tokens = tokens
288283 } ;
289284
290- string category = sortCriterion . Category ;
291- string type = sortCriterion . Type ;
285+ var category = sortCriterion . Category ;
286+ var type = sortCriterion . Type ;
292287
293288 // Find specific sort criterion.
294289 var descriptor = availableSortCriteria
0 commit comments