Can you explain how to work with api which requires "where" statement?

Targutai Yesugei asked on July 17, 2017 15:42


I want to get category by part of it's code name. I'm trying to use PageTemplateCategoryInfoProvider.GetSiteCategoriesList() but it requires string "where" statement which i don't know how to pass.

I tried some SQL-style code like

var categoriesList = PageTemplateCategoryInfoProvider.GetSiteCategoriesList(
            "CategoryName like '%6442498327'", "CategoryID Desc");

but it doesn't work: Additional information: Object type 'cms.class' not found.

Can someone explain me or give a link to a guideline about this kind of Kentico API?

Also, how should i rewrite my code to get categories i want?

Thanks in advance!

Correct Answer

Brenden Kehren answered on July 17, 2017 16:49

If you want to get categories then use something like:

var categories = CategoryInfoProvider.GetCategories().WhereLike("CategoryName", "6442498327").OnSite(SiteContext.CurrentSiteName, false).OrderByDescending("CategoryID");

1 votesVote for this answer Unmark Correct answer

Recent Answers

Targutai Yesugei answered on July 18, 2017 06:01 (last edited on July 18, 2017 06:45)

Thank you, Brenden!

0 votesVote for this answer Mark as a Correct answer

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