When to use DelegateFilterBuilder over FilterExpression

Member since: 2007

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?

#175838 Edited, Mar 03, 2017 16:33