Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kadir 30 posts 80 karma points
    Oct 02, 2014 @ 11:40
    Kadir
    0

    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:

    <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 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

Please Sign in or register to post replies

Write your reply to:

Draft