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.