NewsItem Query

Posted by Community Admin on 04-Aug-2018 07:16

NewsItem Query

All Replies

Posted by Community Admin on 17-May-2011 00:00

Why would this:

var rotatorCategory = new Guid("8C4DACE0-7867-40E5-B261-E963AB672E4B");
var content = App.WorkWith().NewsItems()
                            .Publihed()
                            .Where(ci => ci.GetValue<IList>("Category").Contains(rotatorCategory))
                            .Get();
 
rotator.DataSource = content.ToList();
rotator.DataBind();

be throwing this:

NonGeneric method 'object GetValue(string fieldName)' is not supported in LINQ queries. Use generic 'TValue GetValue<TValue>(string fieldName)' instead.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: NonGeneric method 'object GetValue(string fieldName)' is not supported in LINQ queries. Use generic 'TValue GetValue<TValue>(string fieldName)' instead.

Source Error: 

Line 19:                 .Where(ci => ((IList<Guid>)ci.GetValue("Category")).Contains(rotatorCategory));
Line 20: 
Line 21:             rotator.DataSource = content;
Line 22:             rotator.DataBind();
Line 23:         

Posted by Community Admin on 17-May-2011 00:00

Hello Steve,

Categories are stored in the form of a list of Guids. This means that when you access them you should use:

.Where(ci => ci.GetValue<IList<Guid>>("Category").Contains(rotatorCategory)).Get();

As the error message states.

Regards,
Radoslav Georgiev
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

Posted by Community Admin on 28-May-2011 00:00

This is returning strange results....

I only have 2 news items in this category, but its giving me 4 items back, one is duplicated, the other is blank???

www.screencast.com/.../gasSIJmG

Posted by Community Admin on 30-May-2011 00:00

Hi Steve,

Get the items where c.Status == ContentLifecycleStatus.Live

Regards,
Ivan Dimitrov
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