ClubQuery with attributes



I have a problem when listing clubs. I want to list clubs that are approved, not hidden, sorted on creationdate and with a specific attribute-value. I.e the same as this method but with the addition a specific attribut-value. ClubCollection clubs = ClubHandler.GetClubs(ClubApproval.Approved, ClubHideStatus.NotHidden, page, ucClubs.PageSize, out totalItems, new ClubSortOrder(ClubSortField.Created, SortingDirection.Descending));

If I just filter the resultcollection I will get problems with the paging when "totalitems" and "pagesize" attributes are already set.

I was thinking that a ClubQuery can be the solution to my problem but I don't know how to write taht kind of query with attributes and sorting.

Any suggestions?

Best regards

Oct 05, 2009 11:17

Hi Marcus

I have an example here that might help. but please note that I did it more or less "freehand" from memory so I have not tested it.

ClubQuery clubQuery = new ClubQuery();

clubQuery.IsApproved = new BooleanCriterion();

clubQuery.IsApproved.Value = true;

clubQuery.IsHidden = new BooleanCriterion();

clubQuery.IsHidden.Value = false;

StringCriterion strCriterion = new StringCriterion();

strCriterion.Value = "MyAttributeValue";

clubQuery["MyAttribute"] = strCriterion;

clubQuery.Created = new DateTimeCriterion();

clubQuery.OrderBy.Add(new CriterionSortOrder(clubQuery.Created, SortingDirection.Descending));

ClubCollection clubCollection = QueryHandler.GetQueryResult<Club, ClubCollection>(clubQuery,page,ucClubs.PageSize, out totalItems);

Oct 09, 2009 16:26

Many thanks, Claus!

Best regards

Oct 21, 2009 16:02
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.