Copied to clipboard

Flag this post as spam?

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


  • Ahmed Ramadan 10 posts 100 karma points
    Jan 05, 2019 @ 09:48
    Ahmed Ramadan
    0

    Select content by property value ?

    How can I write the following code at single select statement?

       Category model = new Category();
            model.articles = new List<Article>();
            List<Article> articleList = new List<Article>();
            Article article = new Article();
            var childs = CurrentPage.Children;
            foreach (var content in childs)
            {
                article = new Article();
                article = getArticle(content);
                articleList.Add(article);
            }
            var posts = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf()
                        .Where(x => x.HasProperty("relatedContentItem")).ToList();
            foreach (var content in posts)
            {
                ArchetypeModel fieldsetlist = content.GetPropertyValue<ArchetypeModel>("relatedContentItem");
                foreach (ArchetypeFieldsetModel fieldset in fieldsetlist)
                {
                    if (fieldset.GetValue<IPublishedContent>("article") != null && fieldset.GetValue<IPublishedContent>("article").Equals(CurrentPage))
                    {
                        article = new Article();
                        article = getArticle(content);
                        articleList.Add(article);
                    }
                }
            }
            model.articles = articleList.OrderByDescending(x => x.PublishedDate).ToList();
    
Please Sign in or register to post replies

Write your reply to:

Draft