StrataFrame Forum

Subclass Business Object

http://forum.strataframe.net/Topic16573.aspx

By Aaron Young - 5/25/2008

Hi,

I have a child BO that needs to have many parent relationships. I know one child BO can only have one parent BO so I thought the solution was to subclass the child and set the ParentRelationship for each one. However, when I open the subclassed child BO in the designer, the ParentRelationship option is not visible in the Properties window. However, it is visible for the original child BO that is subclassed to MicroFour.StrataFrame.Business.BusinessLayer.

The strange thing is other SF properties (such as IncludeInFormSave) are visible in the subclassed BOs.

Have I missed something?

Thanks in advance,

Aaron

 

By Trent L. Taylor - 5/26/2008

Have I missed something?

This property is slightly different and can only be seen when using the component designer (not visible from within an instance of an object [i.e. dropped on a form]).  I will work just fine thought if you open the inherited BO within a component designer (i.e. double-click the BO from the solution explorer).

Just FYI, we will be adding the ability to register as many foreign key relationships as you would like.  You will only be able to do one through the standard designer (like now), but in code, you can register as many foreign key relationships as possible.  We have already implemented this within our medical app and it will become part of the framework.  If all works out then it will be in the final 1.6.6 build otherwise it would most definitely be in the 1.6.7 build.

By Edhy Rijo - 5/26/2008

Trent L. Taylor (05/26/2008)
Have I missed something?

Just FYI, we will be adding the ability to register as many foreign key relationships as you would like.  You will only be able to do one through the standard designer (like now), but in code, you can register as many foreign key relationships as possible.  We have already implemented this within our medical app and it will become part of the framework.  If all works out then it will be in the final 1.6.6 build otherwise it would most definitely be in the 1.6.7 build.

Glad to hear about this since I am about to need that functionality in my application next stage. Tongue

You will only be able to do one through the standard designer (like now)

Why? is there a design limitation for this?

By Aaron Young - 5/26/2008

I am actually using the Component Designer (i.e. double-click on the inherited BO in the solution explorer) and the ParentRelationship is missing from the Properties window as below.

Glad to hear you will be offering multiple relationships in 1.6.6 or 1.6.7. Do you have a timescale on this? If it is going to be soon then I will try and wait but I do really have an immediate need for it. If not, then I will subclass the BO provided I can get passed this problem.

Thanks.

By Trent L. Taylor - 5/26/2008

I just created a sample and it worked.  So I guess that question would be more at the root level (your class and subclassed BO).  In fact, we do this ourselves all of the time, so if you have a BO that inherits from BusinessLayer (this would be your base) and then your BO inherits from your base, you should see it.

There is logic to prevent this property from appearing within designer dialogs (i.e. dropped on a form, etc.) so it sounds like something is going on in regards to inheritance.  You might send me a sample of your code so I can see what is going on.

By Trent L. Taylor - 5/26/2008

Do you have a timescale on this?

We have a lot of balls in the air and there are really a lot of new features already being implemented in the 1.6.6 (a lot more than is currently posted on the forum).  It is my desire to wrap up the 1.6.6 beta by the end of June (which would hopefully include this new feature)...but it may not make it into the 1.6.6 build depending on time constraints and testing.

Why? is there a design limitation for this?

This is a lengthy topic...but basicially it isn't necessary.  We have been doing this within our medical app for around a year now so it is tried and testing.  The parent relationship is generally always necessary, however, the foreign key fields may not be.  By placing it in this collection it would always force the foreign key field BO to be present...even when it isn't necessary.  We can talk about this more in class...but there are a lot of reasons and this is the road we initially went down and by pulling it out and putting it into a shared class, we use it for all types of scenarios.  You can even have multiple BOs talking to the same relationship source, etc. which you could not do in a designer type environment.  So it is basically to remove limitations, not create them.

By Aaron Young - 5/26/2008

With the following exceptions, I haven't added any extra code to the BOs beyond what is created as a default.  In the following example, both BOs have been mapped to the same underlying table using the BO Mapper. I then changed the definition of the second DeliveryDistanceEnquiry class to inherit from the original DeliveryDistance class which is inherited from BusinessLayer.

public partial class DeliveryDistance : MicroFour.StrataFrame.Business.BusinessLayer

public partial class DeliveryDistanceEnquiry : DeliveryDistance

I can see ParentRelationship when I open DeliveryDistance in the component designer but I don't see it when opening DeliveryDistanceEnquiry. However, it is worth noting that I can see other SF BO properties when I open the DeliveryDistanceEnquiry in the component designer.

ParentRelationship appears to have been selectively hidden in the designer.

By Trent L. Taylor - 5/26/2008

However, it is worth noting that I can see other SF BO properties when I open the DeliveryDistanceEnquiry in the component designer.

I know, you have mentioned that several times and I had tried to addres this on some other threads and apparently I didn't get my point across.  The ParentRelationship property is treated differently than all other properties.  It is intentionally hidden outside of the component designer, so there is something in the mix that is making this property and the environment that you have setup think that the object you are dealing with is an instance versus a designer window.

I created a sample in C# and it worked as it should.  You might be able to see where your problem is by looking at this code.

By Aaron Young - 5/26/2008

[I know, you have mentioned that several times and I had tried to addres this on some other threads and apparently I didn't get my point across.  The ParentRelationship property is treated differently than all other properties.  It is intentionally hidden outside of the component designer, so there is something in the mix that is making this property and the environment that you have setup think that the object you are dealing with is an instance versus a designer window.

Ah I see what you were saying now - sorry Smile

Okay, thanks for the sample project (which works). I checked and I didn't see any differences between your code and mine. So I added two new BOs and subclassed one from the other. I could see the ParentRelationship from both BOs. The only difference between these new BOs and my original ones is that the latter were both mapped to the same table in the DDT whereas the new BOs were not mapped to anything.

In your sample project you have MyBaseBO and MyInheritedBO. Which one would you map to the table in the DDT? Would you map only one or both?

I think it is breaking in the BO Mapping.

By Aaron Young - 5/26/2008

By the way, the current one parent per BO limitation is the only thing I could complain about SF and it looks like you are removing this issue. Even then it wasn't a big complaint!

I have only been with SF for a couple of weeks and have made BIG progress in converting my app from a rival system. Just wanted to post this as I don't want there to be any confusion as I know they are reading this! Smile

By Aaron Young - 5/26/2008

Using your sample class names, I lose the ParentRelationship when I use the Business Object Mapper to map the MyBaseBO to a table in my DDT. As soon as I do that, I can nolonger see the ParentRelationship in MyInheritedBO.

As I would like to store all my code in MyBaseBO, I would have thought I needed to map it to the DDT to have access to the field names, etc.

By Aaron Young - 5/26/2008

Got there Smile

It works when MyBaseBO is NOT mapped in the BO Mapper and MyInheritedBO is mapped.

No big deal in the end Smile Thanks for the help.

By Trent L. Taylor - 5/26/2008

Glad you got it worked out. Smile