0
在我为我的应用程序构建的新UserViewModel中,我有两个用于存储属性的选项。什么是自定义视图模型中属性声明的最佳实践
第一个选择是让
Public Property user As User ''# Including the entire User object
Public Property custString as String ''# Custom String for View
第二个选项是实际写出所有用户属性
Public Property ID As Integer ''# Declaring each object individually
Public Property UserName As String ''# Here is another object found in User
Public Property RegistrationDate As Date ''# Here is another object found in User
Public Property custStrin As String ''# Custom String for View
谁能告诉我什么是更好的方式做,这是为什么?
我目前得到了第一个选项,但是,我不喜欢它看起来在视图相比,第二个选项的方式
这看起来不错(IMO)
<%: Model.UserName %>
这看起来并不漂亮(IMO)
<%: Model.User.UserName %>
我想你的意思是从<%:Modal.User.UserName%>到'<%:Modal.UserName%>'? – Ahmad 2010-07-12 11:33:12
不是@Ahmad。我目前在ViewModal中有第一个选项。这就是为什么我不得不将代码更改为modal.user.username - 而这看起来很愚蠢。 – 2010-07-12 13:57:29