Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
AI OnAI Off
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Hi Dileep,
TryGet will return the result as Ture or False so you can get in any variable then check it with if condition.
var searchQuery = this._client.Search<T>(); var value= _contentLoader.TryGet<IContent>(optionalContent, out var ContentToFilter); if(value) { searchQuery = searchQuery.Filter(f => !f.ContentLink.Match(ContentToFilter.ContentLink)) }
Then apply the other logic.
Hope it helps
Thanks
Ravindra S. Rathore
I have an EPI find query as below
multisearch = multisearch.Search<GenericPage, SearchHitResult>(s => s
.FilterForVisitor()
.Filter(f => !f.ContentLink.Match(ContentToFilter.ContentLink))
.Skip((page - 1) * pageSize)
.Take(pageSize)
.OrderByDescending(x => x.ArticleDate)
The ContentToFilter is a Page type which I get using content loader as shown below:
_contentLoader.TryGet<IContent>(optionalContent, out var ContentToFilter);
There is a possibility that TryGet will result in null and then the filter line will throw exception. How do I check for null content before applying this filter.