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,
first of all, please excuse me if I can't explain the problem clearly. I have relations where I categories incentives on my site. I display them like below:
<div> @foreach (var item in categoryPage){ RelationType relationType = RelationType.GetByAlias("relateCategoriestoIncentive"); Relation[] relations = Relation.GetRelations(item.Id, relationType); List<int> relationsIds = relations.Select(x => x.Parent.Id).ToList(); var nodeCollection = Library.NodesById(relationsIds).OrderBy("createDate desc"); @foreach (var incentive in nodeCollection){ if (incentive.GetPropertyValue("incentiveRecommended") == "1") { <article> <p>@incentive.incentiveTitle</p> </article> } } </div>
The problem is I can't apply Take(10) method in the right order. What I want to do is:
1- sort all incetives by createDate2- filter the ones that HasValue "incentiveRecommended"3- and Take only 10 from out of theseI can't do the second step, since I have limited coding knowledge. I would be glad if you could guide me through
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
Displaying Relations using Take and HasValue
Hi,
first of all, please excuse me if I can't explain the problem clearly. I have relations where I categories incentives on my site. I display them like below:
The problem is I can't apply Take(10) method in the right order. What I want to do is:
1- sort all incetives by createDate
2- filter the ones that HasValue "incentiveRecommended"
3- and Take only 10 from out of these
I can't do the second step, since I have limited coding knowledge. I would be glad if you could guide me through
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.