In this example, we are using the "productimages" table, although the underlying business object does not at all load or save that table (by default it will only handle its own master entity... in this case "products"). Therefore, we have to add some functionality to the business object to handle this table.
- Override the LoadSecondaryTables() method of the "ItemBusinessObject" class to executes its default behavior, but also load related methods from the ProductImages? table into a new table in the dataset.
- Override the SaveSecondaryTables() method to also save the new table.
- Override the AddNewSecondaryTables() method to add a placeholder table for the product images to the dataset.
Your new business object code should be like this:
Note the use of the BuildSingleRecordQueryCommand() method on the current DataService. This is a generic way of querying a list of fields (all fields (*) in this example), from a certain table (ProductImages), who's identifying field (product_fk) equals a certain value (parentPk). LoadSecondaryTables should always use this method if possible, since it is the easiest way to create a completely database independent command.