Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a docType Actor that has a property alias of age.
I have this query in my view:
var childrenGreaterThanTen = Model.Content.Children.Where(x => x.GetProperty("age").Value > 10 );
But I get an error:
Compiler Error Message: CS1593: Delegate 'System.Func<Umbraco.Core.Models.IPublishedContent,int,bool>' does not take 1 arguments
Am I missing something simple?
aha, for anyone else hitting this, I had to cast the property to an int:
var childrenGreaterThanTen = Model.Content.Children.Where(x => x.GetPropertyValue<int>("age") > 10 );
Yea its because GetPropertyValue returns a string
Be carefull here you have no checking to make sure its an int.
int childrenGreaterThanTen = Model.Content.Children.Where(x => x.GetPropertyValue("age") > 10 );
int childrenGreaterThanTen = 0;
Int32.TryParse(Model.Content.Children.Where(x => x.GetPropertyValue("age") > 10 ) out childrenGreaterThanTen )
this way you can ensure you get an int and nothing will throw if you get a diffrent type :). Charlie
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted