OrderBy custom field does not work

Posted by Community Admin on 04-Aug-2018 11:58

OrderBy custom field does not work

All Replies

Posted by Community Admin on 09-Feb-2015 00:00

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?

Posted by Community Admin on 09-Feb-2015 00:00

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

Posted by Community Admin on 09-Feb-2015 00:00

Thank you Daniel!

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

This thread is closed