KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm looking for some opinions on two different approaches to ViewModel definition I have a Company class public class Company { public string Name { get; set; } public int CountryID { get; set; } } For the Create and Edit views I need a list of Countries to populate a DropDownList for CountryID selection. I can see two broad choices for how to structure the ViewModel that are detailed below. Nested ViewModel public class CompanyCreateEditViewModel { public Company Company { get; set; } public IEnumerable<Country> Countries{ get; set; } .... } Flat ViewModel public class CompanyCreateEditViewModel { public string Name { get; set; } public int CountryID { get; set; } public IEnumerable<Country> Countries{ get; set; } .... } At present I'm favoring the Nested approach as it saves me from defining fields for a second time, but I want to throw it open to better approaches and comments. Thanks
Tags (comma-separated)
Save Edits
Cancel