tags:

views:

40

answers:

2

hello all,

Please provide me a solution for GetByLatest it is giving me an error

How to use this "GetByLatest"

IList<IRss> news = new Trytable().GetByLatest().Cast<IRss>().ToList();

i used this way in the controller,still it is giving an error for getbylatest in the feed method

public static IEnumerable GetByLatest(this IEnumerable unsorted) { return from item in unsorted orderby item.Link descending select item; } public ActionResult Feed() {

        IEnumerable<IRss> news = new IEnumerable<IRss>.GetByLatest().Cast<IRss>().ToList();

            //IList<IRss> news = new Trytable().GetByLatest().Cast<IRss>();
            //return new RssResult(news, "William Duffy - Glasgow Based ASP.NET Web Developer", "The latest news on ASP.NET, C# and ASP.NET MVC ");

    }

please help me

Thanks Ritz

A: 

It should be IEnumerable<IRss>, not IList<IRss>. Or, better yet, use var.

Anton Gogolev
What would the point of calling ".ToList()" to then cast it down to IEnumerable<T>?
Enigmativity
A: 

Assuming that the publication date for an individual RSS item is in the property PubDate and Trytable() returns an IEnumerable<IRss>, GetByLatest would look something like this:

public static IEnumerable<IRss> GetByLatest(this IEnumerable<IRss> unsorted)
{
    return from item in unsorted
           orderby item.PubDate descending
           select item;
}
Hirvox