AI OnAI Off
If it's empty I'd imagine it'll be ContentReference.Empty so I'd suggest writing and exclude filter for any that match that.
query = query.Filter(x => !(x as NewsroomDetailPage).Asset.Match(ContentReference.Empty)); should work as Scott suggested
or you can write something like
public static FilterExpression<ContentReference> IsEmpty(this ContentReference value)
{
return new FilterExpression<ContentReference>(x => ContentReference.IsNullOrEmpty(x));
}
We have "NewDetailPage" and it has an 'asset type' field. Asset type field is ContentReference type.
Now we are showing two kinds of assets in the find results by following the below approach.
query = query.FilterByExactTypes(new List<Type> { typeof(NewsroomDetailPage) });
query = query.Filter(x => !(x as NewsroomDetailPage).Asset.Match(new ContentReference(22))); // news releases
query = query.Filter(x => !(x as NewsroomDetailPage).Asset.Match(new ContentReference(9987))); //videos
But how can we exclude the if the Asset Type field was empty?