没有绑定的MVC 3模型属性

时间:2012-10-26 14:34:46

标签: asp.net-mvc vb.net asp.net-mvc-3

是否可以在未绑定到数据库的模型中包含属性?例如:

Public Class Tbl_Forum_Topic

    <Key()> Public Property FTopic_ID() As Integer
    <ForeignKey("Tbl_Forum")> _
    Public Property FTopic_Forum_ID() As Integer
    Public Property FTopic_Employee_ID() As Integer
    Public Property FTopic_Resource_ID() As Integer
    Public Property FTopic_Title() As String
    Public Property FTopic_Content() As String
    Public Property FTopic_Create_Date() As Nullable(Of Date)
    Public Property FTopic__Deleted() As Nullable(Of Boolean)
    Public Property FTopic_Deleted_Date() As Nullable(Of Date)
    Public Property FTopic_Status() As Nullable(Of Boolean)
    Public Property FTopic_Publish() As Nullable(Of Boolean)

    Public Overridable Property Tbl_Forum() As Tbl_Forum

    Public Overridable Property Tbl_Forum_Replies() As ICollection(Of Tbl_Forum_Reply)

    Public Overridable Property Last_Reply_User_Name() As String

End Class

最后一项称为Last_Reply_User_Name()。它不在我的数据库中,但我想在我的控制器操作中循环并执行计算,以根据其他数据库表中的值进行设置。我在尝试此代码时收到错误Invalid column name 'Last_Reply_User_Name'.

谢谢。

1 个答案:

答案 0 :(得分:3)

您需要将<NotMapped>属性应用于该属性。

相关问题