0

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

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'.尝试此代码时出现错误。

谢谢你。

4

1 回答 1

3

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

于 2012-10-26T14:39:14.067 回答