Implementing the Collection

  1. Create a new class called "ProductImagesCollection"

  2. Add a constructor that takes a reference to the parent entity as a parameter.

  3. Change the class so it inherits from EPS.Business.BusinessObjects.EntitySubItemCollectionItem
    • Note that this automatically adds an overrides for the GetItemObject() method. If this doesn't happen automatically, add it yourself. In this method, instantiate the class "ProductImageEntity" (See sample VB C# Code) and return it.
    • Note that there also is a Configure() method that has been added automatically. Set the strPrimaryKeyField, strForeignKeyField, strParentTableName, and strParentTablePrimaryKeyField properties in this method.

  4. We now also need to override the object's indexer, which will allow us to access sub-items by ID.
    • Note that this functionality is already implemented in the base class. However, the base entity collection class deals with generic sub-item entities, while we are more interested in Product Image Entities. Therefore, we simply use the base class behavior, and type-case it's return value to the type we are creating in GetItemObject()

  5. At this point, we can do anything we need to do with this sub-entity collection, except adding new entities in a meaningful fashion. Most likely, when we want to add a new image, we want to always add an image and a short description. Therefore, we need to add (overload) a new Add() method, with these parameters.
    • Use the AddNewRow() method to add a row to the internal data set, and then set the Label and Bitmap properties to the new value (See sample VB C# Code) ;


Last Updated: 8/7/2006