ClubQuery with attributes

Vote:
 

Hi!

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
Marcus

#33189
Oct 05, 2009 11:17
Vote:
 

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);

#33378
Oct 09, 2009 16:26
Vote:
 

Many thanks, Claus!

Best regards
Marcus

#33878
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.