Retrieving Generic List Items

Posted by Community Admin on 03-Aug-2018 16:01

Retrieving Generic List Items

All Replies

Posted by Community Admin on 22-Jul-2011 00:00

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

Posted by Community Admin on 22-Jul-2011 00:00

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?

Posted by Community Admin on 25-Jul-2011 00:00

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

This thread is closed