More in this section
Forums / Developing with Sitefinity / OrderBy custom field does not work

OrderBy custom field does not work

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. Anatoli Malev
    Anatoli Malev avatar
    2 posts
    23 Sep 2009
    09 Feb 2015
    Link to this post

    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?

  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    18 Feb 2004
    09 Feb 2015 in reply to Anatoli Malev
    Link to this post

    Hi Anatoli,

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


  3. Anatoli Malev
    Anatoli Malev avatar
    2 posts
    23 Sep 2009
    09 Feb 2015 in reply to Daniel Plomp
    Link to this post
    Thank you Daniel!

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

3 posts, 0 answered