This project is read-only.

Sort for TotalViews

Topics: Customizing Orchard
Dec 23, 2011 at 5:19 PM


I try to sort my list following order

UserViewPart part;           

            var containers = _contentManager.Query<ArticlesPart, ArticlesPartRecord>(VersionOptions.Latest).List();

            var descendingOrder = part.TotalViews == (int)OrderByDirection.Descending;
            containers = containers.OrderBy<ArticlesPart, ArticlesPartRecord>(part.TotalViews, descendingOrder);

But this raise compile error

Error 2 Instance argument: cannot convert from 'System.Collections.Generic.IEnumerable<eProp.Articles.Models.ArticlesPart>' to 'System.Linq.IQueryable<eProp.Articles.Models.ArticlesPart>' E:\Arruni\Arruni\Sean Baumann\Orchard\src\Orchard.Web\Modules\eProp.Articles\Services\ArticleService.cs 61 26 eProp.Articles


How can i correct this?



Dec 23, 2011 at 8:30 PM

You're probably missing a using System.Linq statement, but one also has to wonder why you don't do the orderby before you call List?

Dec 25, 2011 at 7:21 AM

I have use this code

return _contentManager.Query<UserViewPart>().List().OrderBy(bc=>bc.As<UserViewPart>().TotalViews );   


List is comming, but its not sort order for totalview


Dec 25, 2011 at 4:43 PM


I have created my own widget for that

Here is video how u can use it