Generic BusinessBase Child?

Generic BusinessBase Child?

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


JonM posted on Wednesday, April 02, 2008

I have a business object.  One of its members will be another business object.  The problem is that depending on what the object is, the child member business object will be different.  Is there any way to define the child member as a BusinessBase without specifying a specific type?  or do I just have to use an Object?

ajj3085 replied on Wednesday, April 02, 2008

You could use an interface to define the child.  However, if the children won't share any interface, you probably have a design flaw somewhere.

JonM replied on Wednesday, April 02, 2008

I thought about an interface.  The children really don't have anything in common.  Basically, I've got a collection of Profiles and depending on what type the profile the child object needs to be something different.  I was hoping I could just define the child as some sort of businessbase object that I could call the standard Update/Save methods on.

ajj3085 replied on Wednesday, April 02, 2008

It sounds like each profile type should have it's own .Net type and associated child type.

rsbaker0 replied on Wednesday, April 02, 2008

Hmmm, object design issues aside,

why can't you have something (roughly) like:

class ProfileBase<T, C> : BusinessBase<T>

{

C _child;

...

}

ajj3085 replied on Wednesday, April 02, 2008

Well, that may get the OP what he wants.. but he still has to figure out how to allow the user to edit the object, because you can't count on child having any paritcular properties. 

Also, if he's using 3.0.x, he may not be able to properly handle child events.

Copyright (c) Marimer LLC