Buddy classes and ViewModels in MVC?
As far as I understand "Buddy Classes" is one way to add data annotations to an EF-crea开发者_StackOverflow社区ted class. To add values for a dropdown, or to use a subset of properties in a View however - a ViewModel is adviceable. Is that correct? Or can I combine the two in one buddyviewmodelclass?
This is a bit confusing. It would be awesome to model up a class with data annotations and all in EF designer.
Yes, you got it right. A view model is a class that reflects all the specific properties of a given view. This view model could be composed of multiple model classes or be a subset of a single model class. This will depend on your model classes and the requirements of your views.
精彩评论