1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Retrieving Generic List Items

Retrieving Generic List Items

3 posts, 0 answered
  1. Paul
    Paul avatar
    24 posts
    Registered:
    16 May 2011
    22 Jul 2011
    Link to this post
    Hi,

    I have created a new "List" (Content > Lists)  named "Quotes", into which I have published two List Items.

    I am trying to retrieve the list as follows:

    var quotesContent = App.WorkWith().Lists().Where(itm => itm.Title = "Quotes" && itm.Status == ContentLifecycleStatus.Live).Get().SingleOrDefault();

    However, quotesContent is returned as null. Any thoughts as to what I am doing wrong, or how to fix this?

    Thanks,
    Paul

  2. Paul
    Paul avatar
    24 posts
    Registered:
    16 May 2011
    22 Jul 2011
    Link to this post
    OK, I thought this was being caused because I was using the assignment operator, not the equality!

    I corrected it to read:

    var quotesContent = App.WorkWith().Lists().Where(itm => itm.Title == "Quotes" && itm.Status == ContentLifecycleStatus.Live).Get().SingleOrDefault();

    However this still doesn't work. However, if I remove the status check

    var quotesContent = App.WorkWith().Lists().Where(itm => itm.Title == "Quotes").Get().SingleOrDefault();

    it does - but the list is published! Any idea why this might be?
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    25 Jul 2011
    Link to this post
    Hello Paul,

    The query will always return null, as the List itself does not have Content LifeCycle implemented, its list items do, that's why removing the filter returns the proper content (you'll notice the same behavior for Blogs, for example). As you can observe, a List can only be created and deleted, it does not go through Master->Draft->Live statuses. For more information, please consult our Lists API.

    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered