protected virtual TQuery FilterFor <TQuery, TObject>(IDocumentQuery <TQuery, TObject> query, SiteCulture?siteCulture = default) where TQuery : IDocumentQuery <TQuery, TObject> where TObject : TreeNode, new() { var typedQuery = query.GetTypedQuery(); typedQuery .OnSite(_repositoryServices.SiteService.CurrentSite.SiteName); if (siteCulture != null) { typedQuery.Culture(siteCulture.IsoCode); } if (_repositoryServices.SiteContextService.IsPreviewEnabled) { typedQuery .LatestVersion() .Published(false); } else { typedQuery .Published() .PublishedVersion(); } return(typedQuery); }
protected virtual TQuery EnsureSyntheticFields <TQuery, TNode>(IDocumentQuery <TQuery, TNode> query) where TQuery : IDocumentQuery <TQuery, TNode>, new() where TNode : TreeNode, new() { if (query == null) { throw new ArgumentNullException(nameof(query)); } var publishedColumn = new QueryColumn("CASE WHEN DocumentPublishFrom IS NOT NULL THEN DocumentPublishFrom ELSE DocumentCreatedWhen END"); var modifiedColumn = new QueryColumn($"CASE WHEN DocumentModifiedWhen IS NOT NULL THEN DocumentModifiedWhen ELSE {publishedColumn} END"); var typedQuery = query.GetTypedQuery(); typedQuery = typedQuery.AddColumns( publishedColumn.As(SyntheticDocumentFields.PublishedAtDate), modifiedColumn.As(SyntheticDocumentFields.ModifiedAtDate) ); return(typedQuery); }