I have a multilist field (Product Category). I am getting a list of Product Category from the session. How can i write a predicate to filter all those items which has one common category without custom field

1 Answer 1


You can loop through categories from the session and check if categories from the product contain any of them:

var query = PredicateBuilder.And<ProductSearchItem>();

if (categories.Any())
    var categoryExpression = PredicateBuilder.False<ProductSearchItem>();

    foreach (var category in categories)
        categoryExpression = categoryExpression.Or(p => p.Categories.Contains(category));

    query = query.And(categoryExpression);
  • foreach (var category in categories) { var normalizedID = Sitecore.ContentSearch.Utilities.IdHelper.NormalizeGuid(category.ID); predicate = predicate.Or(x => x["categotytype_sm"].ToString().Contains(normalizedID.ToString())); } I did this but its not coming seems while comparing with multilist getting no value Nov 10, 2020 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.