Filter by Category AND Tag in Kentico

Michael Legacy asked on June 29, 2020 20:31

Hey all,

I'm running into a bit of a weird one. It appears that running a query like this:

public DocumentQuery<TDocument> GetDocumentsByTagAndCategory<TDocument>(string category, string tag, string tagGroup) where TDocument : TreeNode, new()
{
    return GetDocuments<TDocument>()
        .WithTag(tag, tagGroup)
        .InCategories(category);
}

Forces the query into an "OR" operator. I'm looking for a way to filter down by tag AND category, as in BOTH have to match. Anyone have any thoughts or have done this before?

Recent Answers


David te Kloese answered on June 29, 2020 20:42 (last edited on June 29, 2020 20:43)

Did you try to explicitly add the .And() in between? Not 100% sure if that works with these...

Not sure if you did but you can also use .GetFullQueryText() on the query to see what it actually send to the DB.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.