I have the following code that works but I would like to combine the if statement in the foreach where clause Note: newsCategory is a custom property on my newsitem template
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc")) { if (page.newsCategory == "Articles") { .... }
How do I combine the if condition in my where clause?
Access Custom template properties in a Macro
I have the following code that works but I would like to combine the if statement in the foreach where clause
Note: newsCategory is a custom property on my newsitem template
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"))
{
if (page.newsCategory == "Articles")
{
....
}
How do I combine the if condition in my where clause?
If you wanted to do it with strongly typed models rather than the dynamic ones, the code would be:
I'm not 100% on the dynamic syntax though. I generally prefer to use the strongly typed stuff, as you get intellisense.
Hope that helps!
I like that. Thanks
is working on a reply...