Guest User

Guest User

  • Tech Writer
  • 4
  • 522

Get Record From Nested Model

Jun 9 2021 7:14 AM

Hello everyone i have use this code for get blog categories data .but here i have face a issue not get Title,UrlSlug,PostDate

customEntityResult.Items.-Title,PostDate and UrlSlug here

BlogPostDataModel-Other data here 

 

private PagedQueryResult<BlogPostSummary> MapBlogPosts(PagedQueryResult<CustomEntityRenderSummary> customEntityResult)
        {
            var Categoryid = Convert.ToInt32(HttpContext.Request.Cookies["CategoryId"]);
            var blogPosts = new List<BlogPostSummary>();             
            var result = customEntityResult.Items.Select(x => (BlogPostDataModel)x.Model).Where(x => x.CategoryIds.Contains(Convert.ToInt32(Categoryid))).ToList();--Here filter Record based on Id 
            int i = 0;
            foreach (var customEntitys in result)
            {
                if (customEntitys.CategoryIds.Any(x => x == Categoryid))
                {                 
                    var blogPost = new BlogPostSummary();
                    blogPost.ShortDescription = customEntitys.ShortDescription;
                    blogPost.TestHtml = Regex.Replace(customEntitys.TestHtml ?? "", "<.*?>|&.*?;", "");                   
                    blogPosts.Add(blogPost);                  
                    i++;
                }
            }