コード例 #1
0
        /// <summary>
        /// This functionality could mostly be achieved via the Provider.Get--Page() method, which
        /// allows selection by nodeAliasPath, but this implementation allows for further refinement if needed.
        /// </summary>
        /// <param name="documentQuery"></param>
        /// <param name="nodeAliasPath"></param>
        /// <returns></returns>
        protected Result <TDocument> GetFirstPageWithNodeAliasPath(DocumentQuery <TDocument> documentQuery, NodeAliasPathQuery query)
        {
            var page = documentQuery
                       .GetLatestSiteDocuments(Context)
                       .Path(query.NodeAliasPath, PathTypeEnum.Explicit)
                       .TopN(1)
                       .FirstOrDefault();

            if (page is null)
            {
                return(Result.Failure <TDocument>($"Could not find {documentQuery.ClassName} page at [{query.NodeAliasPath}]"));
            }

            return(Result.Success(page));
        }