cast System.Collections.Generic.List<Umbraco.Web.Models.DynamicPublishedContent> to Umbraco.Web.Models.DynamicPublishedContentList
I am trying to use a single variable for either
an Examine search :
var Query = (!string.IsNullOrEmpty(Request.QueryString["query"])?Request.QueryString["query"]:"");
var listItems = @CurrentPage
.Search(Request.QueryString["query"]);
or (depending on the parameters) a node.Children - but concatenating several
var rootnodeIdsAR = rootnodeIds.Split(',');
var listItems = getnodeList(rootnodeIdsAR[0]).ToList();
for(var nl = 1; nl < rootnodeIdsAR.Length;nl++){
var listItemstmp = getnodeList(rootnodeIdsAR[nl]);
listItems = listItems.Concat(listItemstmp).ToList();
}
functions{
public Umbraco.Web.Models.DynamicPublishedContentList getnodeList(string parentnodeId){
var parentNode = Umbraco.Content(parentnodeId);
Umbraco.Web.Models.DynamicPublishedContentList nList;
nList= parentNode.Children
.Where("Visible");
return nList;
}
}
Each of the abover works in isolation (ie by letting var listItems handle the type casting) but if I try to get them to work in the same view
cast System.Collections.Generic.List<Umbraco.Web.Models.DynamicPublishedContent> to Umbraco.Web.Models.DynamicPublishedContentList
I am trying to use a single variable for either an Examine search :
or (depending on the parameters) a node.Children - but concatenating several
Each of the abover works in isolation (ie by letting var listItems handle the type casting) but if I try to get them to work in the same view
ie
then I have a problem as I can't declare listItems twice.
I can't seem to be able to cast one as the other.
The reason for the use of a single variable is so I can use the listItems later in various parts of the code)
Not sure if this possible : maybe I'm trying to be too clever!
Solved
System.Collections.Generic.IEnumerable
is working on a reply...