Parent of object as BusinessBase

Parent of object as BusinessBase

Old forum URL: forums.lhotka.net/forums/t/6142.aspx


wjcomeaux posted on Tuesday, January 13, 2009

For those of you who use Codesmith to generate your CSLA you should be familiar with the parent parameter for the child templates. I'm wondering about the validity of passing in BusinessBase as that parent object. The reason is we have run into situations where multiple items want to use the same child. Now, I know that we should create a new child class for each of these use cases but for what we are doing this would basically mean regenerating the exact same files for the child with the only difference being the code for:

where P : ParentObject_EditableRoot1<P> OR where P : ParentObject_EditableRoot2<P>

So, for cases like this, is it acceptable to generate these objects with a parent type of BusinessBase so that no matter what parent uses it, it still works? We've actually implemented a couple objects this way and they seem to work correctly. I'm just wondering if I am going to cause any negative side effects by taking this route.

TIA,

Will

 

JoeFallon1 replied on Tuesday, January 13, 2009

I took a slightly different approach.

After a few years of using CSLA I realized that I only ever need a key value from the Parent object for doing Inserts on related tables. So I only passed the paramter for DataPortal_Insert.

I also created an interface named IParent (which I may need to re-name now that Rocky has one of the same name) that has one Property - Key As Integer. Then I implement the interface in those BOs that have foreign keys and I pass it to the code which can call .Key to get the value regardless of what kind of BO is the actual Parent.

Joe

 

wjcomeaux replied on Tuesday, January 13, 2009

Thanks Joe.

That helps a lot!

Will

 

Copyright (c) Marimer LLC