If i have a model that should contain an collection e.g. book -> authors
how sould i do it
like:
public class Book
{
public string Title { get; set; }
public List<Author> Authors { get; set; }
}
or more like:
public class Book
{
public string Title { get; set; }
public List<AuthorViewModel> Authors { get; set; }
}
which of this both is the more common way to do this and how do i get the view out of the ViewModel?
This one is definitely wrong:
public class Book
{
public string Title { get; set; }
public List<AuthorViewModel> Authors { get; set; }
}
But this would be OK:
public class BookViewModel
{
public string Title { get; set; }
public List<AuthorViewModel> AuthorModels { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With