ASP.NET MVC: ViewModels versus Domain Entities

后端 未结 6 449
太阳男子
太阳男子 2020-12-29 12:04

I\'m building a concept application with MVC 3 in an attempt to learn its ways. I\'ve previously done some very heavy-duty applications in WebForms, using an n-tier approach

6条回答
  •  死守一世寂寞
    2020-12-29 12:37

    Domain models and ViewModels will look very much like each other. However, ViewModels usually contain view logic attributes and properties. Also sometimes data type can be different, for example you might need to define a DateTime property as string just get the validation working without raising any errors.

    I am using AutoMapper to convert from Model to ViewModels/vice versa.

提交回复
热议问题