Closed jeremy-farrance closed 5 months ago
Sorry if I left out the obvious. Above code works fine with other DataSources. My guess is that it has something to do with having children in the result?
I thought I could test that by using a Remove Attribute/Property
Modifier, but even without the Children and Parent fields in the JSON results, AsItems() still fails, same errors.
Okay, I got this working. I don't believe there was a bug. I just had to adjust how I was using AsItems(). The final working code:
<h4>Version 1: From Query.GetStream Default</h4>
<pre>
@foreach (var page in AsItems(query.GetStream("Default")))
{
<span>@page.Id - @page.String("Name"), ParentId=@page.Int("ParentId")</span>
}
</pre>
awesome, thanks.
I'm submitting a
[x] bug report
...about
[x] Razor templating, C#
Expected Behavior
In previous versions you could use
App.GetQuery("Query Name")
wrapped in AsItems() to easily loop through pages using the Pages DataSource.Current Behavior in 2sxc v17.06.03
Using code very similar to the tutorial example Data and Query - MyData, App.GetQuery() and AsItems(), expand Get data from a Query using App.GetQuery( ... ) - I am getting the following error. This happens with or without params and also whether or not I add .GetStream("Default"):
The failing code is:
The error when we add .GetStream():
The only code change for the slightly different error:
The Visual Query works fine and returns the expected number of pages, 184:
Instructions to Reproduce the Problem
Make the simplest query you can using the Pages DataSource returning all values to the Default stream. Try my code above or use the Tutorial linked above as reference.
Your environment