OrderBy custom field does not work - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

OrderBy custom field does not work

  • OrderBy custom field does not work
  • I am using Telerik Sitefinity v7.3.5610.0.
    I have used this approach before and it worked fine in version 6.3.

    Now the following code pulls out the records, but it does not OrderBy:


    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
    Type faqCategoryType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.FAQ.FaqCategory");
    IQueryable<DynamicContent> faqCategories = dynamicModuleManager.GetDataItems(faqCategoryType).Where(c => c.Status == ContentLifecycleStatus.Live && c.WasPublished == true);
     
    //var sortedFaqCategories = faqCategories.OrderBy(o => o.GetValue<decimal?>("CategoryOrder"));
     
    faqCategories = faqCategories.OrderBy(o => o.GetValue<decimal?>("CategoryOrder"));
     
    foreach (var faqCategory in faqCategories)

        Type questionType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.FAQ.Question");
        var questionsPerFaqCategory = dynamicModuleManager.GetChildItems(faqCategory, questionType).Where(c => c.WasPublished == true).Take(3).OrderBy(o => o.GetValue<decimal?>("FaqOrder"));
     

    I have tried couple of variations but to no avail.

    Any suggestions of what might went wrong?

  • Hi Anatoli,

    I think this is the right approach, although I would think that you first should do the OrderBy before the Take?

    Best,
    Daniel

  • Thank you Daniel!

    I had tried that before I posted the description of my problem. ... But as I said not much of a luck.