I am getting error in a Umbraco 7.0.3 macro which traverse through all the childs and returns little more than a list. To start with I have used Umbraco back office to build the basic navigation and side menu items. Meanwhile once the local environment is setup I started working locally.
The issue is, the code I had build using back office for navigation works fine but same code does not work if the items are created in VS2012 Ultimate version, even i just paste the same code from original working navigation macro.
I am getting following error : 'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Any', suggesting that the page list is dynamic. To my amusement, the same code work for existing navigation, then why not with new items? Is there any setting in VS2012 where it is marking the file unusable with UTF8 editors or non-valid html?
My question is how can I find count or Any items in a razor macro? I have already tried Enumerable items count and any methods, but no use.
Any pointers on how to find number of items exists will be helpful.
I am providing some more information on Paulo's request. Erroring on "startNode.Children.Where("Visible").Any()" line. Following is the macro code:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
=== Macro Parameters To Create ===
Show:True Alias:nodeId Name:Node ID Type:Content Picker
*@
@if (Model.MacroParameters["startNodeID"] != null)
{
@* Get the start node as a dynamic node *@
var startNode = Umbraco.Content(Model.MacroParameters["startNodeID"]);
if (startNode.Children.Where("Visible").Any())
{
<div class="container">
<div class="row">
@foreach (var page in startNode.Children.Where("Visible"))
{
<div class="col-sm-3 col-md-3">
<div class="thumbnail">
<img src="~/images/Tiles/300x200.jpg" alt="@page.Name">
<div class="caption">
<h3><a href="@page.Url">@page.Name</a></h3>
<p>@page.GetPropertyValue("summary").Substring(0, 100)</p>
<a href="@page.Url" class="btn btn-default">Read More</a>
</div>
</div>
</div>
}
</div>
</div>
}
}