I'm using the new DataQuery methods to get my documents and it errors out when I try to bind the results to a grid. Here is my somewhat simple query:
DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(className); if (dci != null) { string orderColumns = "BlogPostDate"; if (className.ToLower() == "bluepillar.resource") { orderColumns = "NodeLevel, NodeOrder, NodeName"; } var docs = DocumentHelper.GetDocuments(className) .OnSite(SiteContext.CurrentSiteName) .Path(aliasPath, PathTypeEnum.Children) .Culture("en-us") .OrderBy(OrderDirection.Descending, orderColumns) .CombineWithDefaultCulture(true); docs.Offset = offset; docs.MaxRecords = 6; gv1.DataSource = docs.Execute(); gv1.DataBind(); }
This is the exact error:
[DataQuery.GenerateQueryText]: The paged query cannot be generated without the orderBy set.
Any ideas on what's going on?
Maybe orderColumns should be an array:
string[] orderColumns = { "BlogPostDate" };
You might need to use .Page(int pageIndex, int pageSize)
instead of
docs.Offset = offset; docs.MaxRecords = 6;
Happens with Page as well. Removing the .CombineWithDefaultCulture() fixed it for me. Might be a bug.
.CombineWithDefaultCulture()
Kentico Support stated its a limitation with pre 8.1 and has been resolved in the new release (8.1) scheduled for next week.
Please, sign in to be able to submit a new answer.