正如主題所說......這個問題是關於爲我的項目設置正確的結構。如果你認爲有更好的地方提出這個問題,那麼請提供建議。使用MVC的項目結構4
我有一個使用ET &存儲庫模式的MVC 4項目。此時,我有DAL & UI層。
當前我正在使用我的DAL進行數據訪問,並在我的數據訪問層中創建了我的接口& ViewModels。我有一種感覺,我做錯了。這裏是我的樣本設置。
MY DAL層(其包括下面的接口,回購&視圖模型)
DAL.ViewModel
Public Class ProductSummaryViewModel
Property productGUID As Integer
Property productName As String
End Class
DAL.Interface(對於Repostiory圖案)
Public Interface IProductRepository
Property ProductIdentityID As Integer
Property ImageMainPath As String
End Interface
個DAL.Products庫
Public Class productsRepository
Implements IProductRepository
Private _db As websolutionsEntities = New websolutionsEntities()
Public Function AddProduct(ByVal prdSummary As ProductSummaryViewModel) As Boolean Implements IProductRepository.AddProduct
_db.AddProduct(prdSummary)
Return true
End Function
這裏是我的控制器
Private ProductRepoitory As DAL.IProductRepository
Sub New()
Me.new(New DAL.productsRepository())
End Sub
Sub New(ByVal repo As DAL.IProductRepository)
repo = ProductRepoitory
End Sub
Public Function AddItem(ByVal prd As DAL.ProductSummaryViewModel) As ActionResult
Dim test as boolean = DAL.ProductRepoitory.AddItem(prd)
End Function
我的項目將在不久的將來成長,所以我要正確設置它,但我不希望讓別人和我自己也變得太複雜。請告知您的建議。
我可以給你的最好的建議是使用[commands](http://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=91)和[queries]( http://www.cuttingedge.it/blogs/steven/pivot/entry。PHP?ID = 92)。 – Steven
我對實現Business/Domain層更感興趣,但不知道如何實現這一點,以及在哪一層我應該創建我的接口和ViewModels。 – highwingers