DrM wrote:
I've gone with the Adapter model after your advice the last few days. Now I need to extend one of the classes.
I have a table called Site in the database which results in LLBLGen producing a SiteEntity and a SiteEntityFactory.
I need this class to have a number of additional properties. So I read the section on "Extending the framework" in the docs and need some guidance here.
Do I need to derive two new classes or one to do this.
Do I need to derive a new MySiteEntity as well as a MySiteEntityFactory?
You need to derive from the factory class to produce MySiteEntity objects. You then also derive a new class from SiteEntity and call that MySiteEntity and you add some constructors to that class as shown in the documentation.
If so do I also need to override all the constructors? Am I missing something here?
You should at least implement the constructor which accepts an IEntityFields2 object and the one which accepts the PK fields. (simply copy them over from the class you're inheriting from, empty the body and add :base(_parameters_) to the header (and change the names of course)
Because you created a new type, entities which relate to SiteEntity have to know that the reference they hold should be a MySiteEntity reference, that is, if you want to have that. That's the reason why I also derived from Customer in the documentation, so I could specify that 'Orders' contains MyOrderEntity objects and that when I use MyCustomerEntity objects somewhere (in a collection, in a grid) the Orders collection will contain/should contain MyOrderEntity objects. This then will result in a bound grid that the extra properties added in MyOrderEntity are added to the grid, because when I navigate from MyCustomerEntity to its Orders collection, the grid thinks it sees MyOrderEntity objects, due to the fact I've specified that in MyCustomerEntity, as shown in the documentation.
It might be a little cumbersome at first, but it will turn out to be more flexible in the end.