我正在尝试使用产品类实体、抽象存储库和带有示例数据的假存储库来创建域模型。
我创建了以下产品类
Namespace Entities
Public Class Product
Dim _ProductID As Integer
Dim _Name As String
Dim _Description As String
Dim _Price As Decimal
Dim _Category As String
Public Property ProductID() As Integer
Get
Return _ProductID
End Get
Set(ByVal value As Integer)
_ProductID = value
End Set
End Property
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property
Public Property Price() As Decimal
Get
Return _Price
End Get
Set(ByVal value As Decimal)
_Price = value
End Set
End Property
Public Property Category() As String
Get
Return _Category
End Get
Set(ByVal value As String)
_Category = value
End Set
End Property
End Class
End Namespace
以及如下界面:
Namespace Abstract
Public Interface IProductsRepository
ReadOnly Property Products() As IQueryable(Of Product)
End Interface
End Namespace
我现在需要使用通用 LINQ 列表创建数据,但是我被卡住了,这是我目前所拥有的,但我无法添加项目:
Imports DomainModel.Abstract
Imports DomainModel.Entities
Namespace Concrete
Public Class FakeProductsRepository
Implements IProductsRepository
Private Shared fakeProducts As IQueryable(Of Product) = New List(Of Product)().AsQueryable
Public ReadOnly Property Products() As System.Linq.IQueryable(Of Entities.Product) Implements Abstract.IProductsRepository.Products
Get
Return fakeProducts
End Get
End Property
End Class
End Namespace
样品项目:
fakeProducts.Add(New Product() With {.Name = "Football", .Price = 25})
非常感谢帮助..