我遇到了一个真正的问题,我知道这是因为我知道的不够多。我已经搜索了大约 50 篇文章,但找不到答案。
这是我的域模型
Namespace Models
Public Class Article
Public Property ArticleId As Integer
Public Property Author As String
<DisplayFormat(DataFormatString:="{0:D}")>
Public Property CreatedOn As DateTime
<DisplayFormat(DataFormatString:="{0:D}")>
Public Property LastModified As DateTime
<AllowHtml()>
Public Property Content As String
Public Property Title As String
Public Property Excerpt As String
Public Property IsPublic As Boolean
Public Overridable Property Category As ICollection(Of Category)
Public Overridable Property Tags As ICollection(Of Tag)
Public Overridable Property Status As ICollection(Of Status)
Public Overridable Property Comments As ICollection(Of Comment)
End Class
End Namespace
Namespace Models
Public Class Status
Public Property StatusId As Integer
Public Property Name As String
Public Overridable Property Articles As ICollection(Of Article)
End Class
End Namespace
Namespace Models
Public Class Category
Public Property CategoryId As Integer
Public Property Name As String
Public Overridable Property Articles As ICollection(Of Article)
End Class
End Namespace
Namespace Models
Public Class Tag
Public Property TagId As Integer
Public Property Name As String
Public Overridable Property Articles As ICollection(Of Article)
End Class
End Namespace
这是我的 ViewModel(基于我的域模型)
Namespace ViewModels.Admin
Public Class ArticleViewModel
Public Property Article As Article
Public Property CategoryId As Integer
Public Property StatusId As Integer
Public Property Tags As ICollection(Of Tag)
End Class
End Namespace
我不知道如何保存所有这些数据交叉模式。我现在尝试了很多方法,我不知道在哪里看。我已经尝试了几本书,但没有人真正深入研究这一点。我还查看了 Contoso 大学项目,但它似乎不像我的项目。任何人都可以帮忙吗?