I have a MVC model oject that contains a collection of object. I want to expose the MVC model as user input fields on a MVC view.
Below is MVC model and domain model
public class BookModel
{
public BookModel(Book book)
{
this.Authors = book.Authors;
}
public List<Author> Authors { get; set; }
}
public class Book
{
public List<Author> Authors = new List<Author>();
}
public class Author
{
public string Name { get; set; }
}
Below is the Action method in controller:
public ActionResult Edit(int id)
{
BookModel model = GetBookModel(id);
return View(model);
}
The problem is that, the generated view (*.cshtml) does NOT have the input fields for the collection authors.
Any idea would be very much appreciated.