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)

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?

Correct Answer

David te Kloese answered on June 29, 2020 20:42

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 Unmark Correct answer

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