Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter S 64 posts 106 karma points
    Feb 03, 2010 @ 16:32
    Peter S
    0

    linq result always 0 for BlogPosts

    I've created a custom usercontrol to get some of the most recent blogposts, but for some reason I keep getting no results from linq.
    Here's the method that is supposed to get the blogposts:

    private IEnumerable<BlogPost> getBlogItems()
            {
                myContext = new Outpost11DataContext();
                var result = (from p in myContext.BlogPosts
                             orderby p.CreateDate descending
                              select p).Take(NumberOfItems);
                return result;
            }

    I have a similar method for NewsItems, which does return the right content.

    At the moment I have 2 test blogposts that are published. I made sure the document type for both posts are 'BlogPost'. I created the datacontext code from the document types.

    And I'm using Blog4Umbraco.

    Can anyone point me in the right direction?

     

  • Peter S 64 posts 106 karma points
    Feb 04, 2010 @ 13:28
    Peter S
    0

    Problem solved (sortof). I was not getting any results in my development environment, but after quickly testing it on the live server, everything turned out to be working ok.

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Feb 04, 2010 @ 23:03
    Aaron Powell
    0

    Most likely cause is there was no items in the XML cache with the alias of the document type.

Please Sign in or register to post replies

Write your reply to:

Draft