I would like to display tags as a list of items rather than a count.


<div class="display-label">Tags</div>
<div class="display-field">@(Model.Tags == null ? "None" : Model.Tags.Count.ToString())</div>


public class Post
    public int PostId { get; set; }

    public string Title { get; set; }
    public string Body { get; set; }
    public DateTime CreatedAt { get; set; }
    public virtual ICollection<Tag> Tags { get; set; } 


public class Tag

        public int TagId { get; set; }
        public string Name { get; set; }

        // Relationship with Post
        public int PostId { get; set; }
        public virtual Post Post { get; set; } // This is new


I tried List, Ilist, Enumerable in the Details.cshtml view file. I want to display the list of Tags as strings for each post.

Related posts

Recent Viewed