VB.NET Code to Implement a Child Collection

Back to Implementing the Collection
Imports System.Drawing Imports System.IO Public Class ProductImagesCollection Inherits EPS.Business.BusinessObjects.EntitySubItemCollection Public Sub New(ByVal parentEntity As IBusinessEntity) MyBase.New(parentEntity) End Sub Protected Overrides Sub Configure() Me.PrimaryKeyField = "image_pk" Me.ForeignKeyField = "product_fk" Me.ParentTableName = "products" Me.ParentTablePrimaryKeyField = "product_pk" End Sub Public Overrides Function GetItemObject() As EPS.Business.BusinessObjects.EntitySubItemCollectionItem Return New CType(ProductImageEntity, EntitySubItemCollectionItem?) End Function Default Public Shadows ReadOnly Property Item(ByVal index As Integer) As ProductImageEntity Get Return CType(Me.GetItemByIndex(index), ProductImageEntity) End Get End Property ' Add this method only if needed... Public Overloads Sub Add(ByVal label As String, ByVal image As Bitmap) Dim entImage As ProductImageEntity = CType(Me.AddNewRow(), ProductImageEntity) entImage.Label = label entImage.Image = image End Sub End Class

Back to Implementing the Collection


Last Updated: 8/10/2006