For example I have 2 models that Topic and Comment.
1 Topic can have some Comment, so in my Topics class I have an ICollection feid:
public class Topic
{
//........................
public virtual ICollection<Comment> Comments { get; set; }
}
And I call it by this stament:
var topic = db.Topics.Include("Comments").Single(d => d.TopicId == someid)
The code will load for me all the Comment thats belong to my current Topic, so I can print all my comment out by this code:
@foreach (var comment in topic.Comments)
{
<div>@comment.CommentContent</div><hr />
}
The issue is I want to re-oder my Comments list, but I donot know HOW! Please some one show me the right way!
Thanks all of you so much!
1 Answer