Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

When to use DelegateFilterBuilder over FilterExpression

$
0
0

Hi,

When would one use DelegateFilterBuilder instead of FilterExpression (and vice versa)? E.g. I can achieve same (sort of) functionality with:

public static FilterExpression<ContentReference> In(this ContentReference value, IEnumerable<ContentReference> values)
{
    var ids = values.Select(x => x.ID);
    return new FilterExpression<ContentReference>(x => x.ID.In(ids));
}

and:

public static DelegateFilterBuilder In(this ContentReference value, IEnumerable<ContentReference> values)
{
    var ids = values.Select(x => x.ID);
    var fieldFilterValues = ids.Select(FieldFilterValue.Create);
    return new DelegateFilterBuilder(field => new TermsFilter(field + ".ID$$number", fieldFilterValues));
}

Another question regarding my last code snippet, is there a way to express the ID property of a ContentReference without the ugly string concatenation?


Viewing all articles
Browse latest Browse all 6894

Trending Articles