Order by Custom Image Field

Posted by Community Admin on 04-Aug-2018 22:03

Order by Custom Image Field

All Replies

Posted by Community Admin on 05-Feb-2013 00:00

I created a custom integer field for images called "Order".   I found I can get this data by doing this: 

string order = Telerik.Sitefinity.Model.DataExtensions.GetValue(myImage, "Order").ToString();

So I could do custom ordering, However what I would like to do is take my list of Images and use the OrderBy clause.

var images = App.WorkWith().Images().Where(im => im.Parent.Title == "rotator" && im.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get();
 
        foreach (Telerik.Sitefinity.Libraries.Model.Image v in images.OrderBy(im => im.Title))
        
            sb.Append("<li><img class='sliderImage' src='" + v.MediaUrl + "'></img></li>");
        

The example above shows how I can order by the strongly typed properties and that works fine.  I tried to combine the above two code snippets to figure out how I can order by my custom field but I haven't had any luck.  Is this possible?  And if you can can someone post a code snippet of how to do it?

Thanks!

Coty

Posted by Community Admin on 06-Feb-2013 00:00

Bump.

Is it possible to get an answer on this today?  If it is not possible to order by a custom field than I can write my own but I would like to know before I start, thanks!

This thread is closed