Flat vs Nested ViewModel Classes in ASP.NET MVC

I personally prefer the nested approach for presentation because it leads to a more logical design when you use partial views. You might have a CompanyPartialView used all across the application that knows how to render a Company, so it makes a lot of sense to expose the Company as a nested structure.

On the other hand, flat ViewModel classes are the easiest to work with for data entry. You just have a bunch of form fields that all map to individual properties. So my strategy is usually to flatten them for data entry pages and nest them for presentation/report pages.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)