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
Hi all,
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?
TIA
Jay
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 );
do
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...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Error when running lambda query in Razor
Hi all,
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?
TIA
Jay
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 );
do
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...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.