【发布时间】:2013-02-23 20:42:59
【问题描述】:
以下可以吗?我知道领域模型不应该在视图中使用,但是在视图模型中使用领域模型可以吗?对于一些非常小的模型,为它们创建和管理视图模型似乎不值得。
举例
public class LoginDomainModel
{
public string Email { get; set; }
public string Password { get; set; }
public string DisplayName { get; set; }
public long UserTypeID { get; set; }
public virtual UserType UserType { get; set; }
}
public class UserTypeDomainModel
{
public UserType()
{
this.Logins = new List<Login>();
}
public long UserTypeID { get; set; }
public string UserType { get; set; }
public string Description { get; set; }
public virtual ICollection<Login> Logins { get; set; }
}
public class LoginViewModel
{
public string Email { get; set; }
public long UserTypeID {get; set;}
//Right here
public List<UserTypeDomainModel> UserTypesSelectList {get; set;}
}
【问题讨论】:
-
所有很好的答案,谢谢大家。
标签: c# asp.net-mvc