【发布时间】:2012-10-16 20:07:23
【问题描述】:
是否可以在未绑定到数据库的模型中包含属性?例如:
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'.。
谢谢。
【问题讨论】:
-
我假设您实际上是在询问实体框架。
-
我正在使用 ASP.NET MVC 3(已标记)。我没有使用 Code First,数据库已经建立,我只是创建一个模型来镜像它。我不确定 EF 扮演的角色,但我认为它就在某个地方。
标签: asp.net-mvc vb.net asp.net-mvc-3