Try our conversational search powered by Generative AI!

OR search with ClubHandler.GetQueryResult

Vote:
 

Is it possible to do an OR search in ClubHandler.GetQueryResult?

The following code is doing an AND search:

ClubQuery query = new ClubQuery(); query.Name = new StringCriterion(); query.Name.Value = txtSearch.Text; query.Name.WildCardType = WildCardType.Both; query.Description = new StringCriterion(); query.Description.Value = txtSearch.Text; query.Description.WildCardType = WildCardType.Both; ClubCollection clubs = ClubHandler.GetQueryResult(query);

So the question is how this can be changed to return clubs that contain the given text in either the name or the description.

/René

#23889
Sep 18, 2008 10:06
Vote:
 

The solution is the following:

ClubQuery query = new ClubQuery(); CriteriaGroup group = new CriteriaGroup(); StringCriterion nameCriterion = new StringCriterion(); nameCriterion.Value = txtClubsSearch.Text; nameCriterion.WildCardType = WildCardType.Both; query.Name = nameCriterion; StringCriterion descriptionCriterion = new StringCriterion(); descriptionCriterion.Value = txtClubsSearch.Text; descriptionCriterion.WildCardType = WildCardType.Both; query.Description = descriptionCriterion; group.AddCriterion(LogicalOperator.Or, nameCriterion); group.AddCriterion(LogicalOperator.Or, descriptionCriterion); query.AddCriteriaGroup(group); ClubCollection clubs = ClubHandler.GetQueryResult(query);
#24100
Sep 24, 2008 11:11
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.