製品クラスエンティティの抽象リポジトリとサンプルデータを含む偽のリポジトリを使用してドメインモデルを作成しようとしています。
次の製品クラスを作成しました
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})
ヘルプは大いに活用されます。