<div>
@using(Html.BeginForm("AddComment", "Thread", mod))
{
<input type="text" name="AddComment" id="text" />
<input type="submit" value="Save"/>
}
</div>
На моем веб-сайте есть класс потока, позволяющий комментировать каждую тему. Когда веб-сайт загружен, я хочу, чтобы каждый поток загружался в список, и чтобы каждый комментарий к загруженным потокам также загружался одновременно. Как бы я использовал приведенный выше код, чтобы добавить еще один комментарий к существующей теме? Всякий раз, когда я отправляю, это говорит мне, что состояние модели недействительно.
Вот класс резьбы или модель:
public Thread()
{
this.ChildComments = new HashSet<Comment>();
}
public int Id { get; set; }
public string TopicHeader { get; set; }
public string TopicBody { get; set; }
public Nullable<int> UpVotes { get; set; }
public Nullable<int> DownVotes { get; set; }
public int ProfileId { get; set; }
public int TagId { get; set; }
public virtual Profile Profile { get; set; }
public virtual ICollection<Comment> ChildComments { get; set; }
public virtual Tag ThreadTag { get; set; }