StrataFrame Forum

Multipul forms and BO's with a ShardDataTableKey

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

By Scott - 10/17/2006

I have run into a problem using the ShardDataTableKey property on BO's.  I created a SFUser control with a ContactBO on the control, tied to the various controls.  The ContactBO on the usercontrol has its ShardDataTableKey set to 'ContactInfo'.  I then create a new SFStandardForm,  drop a ContactBO on the form, set its ShardDataTableKey to 'ContactInfo', drop the user control with the contact informaiton on it.  Run the form.... works great, the BO on the form and the BO on the usercontrol are one and the same and all the logic built into the user control works.

Open one form, select contact1, open form two, select a different contact... the contact data in now the same in both forms.  I can see that this is exactly what the ShardDataTableKey should do....  how should I handle this type of situation?

By StrataFrame Team - 10/18/2006

You will need to create some sort of "unique" shared data table key.  For instance, when we use the SharedDataTable key internally (such as within a BusinessBindingSource), we use Guid.NewGuid() to create a string that pretty much guaranteed to be unique.  So, you'll probably want to add a method that gets called after the InitializeComponent within your constructor that will "modify" the SharedDataTable keys for the business objects on the control and form.
By Scott - 10/18/2006

Thanks for the info,  will look into doing that.  I knew there had to be a way.

Scott

By StrataFrame Team - 10/18/2006

No problem.  When you change the SharedDataTable key at runtime, the changes within the BO's data will be immediately reflected.
By Scott - 10/18/2006

Just for clairification,  the BOTranslation collection should no longer be used,  right?

The only thing that is shared is the DataTable, NOT the bussiness object and it properties like the BOTranslation did?

BO Properties (includeinformadd, includeinformedit... etc) need to be set on both business objects to function correctly?

Thanks
Scott

By Trent L. Taylor - 10/19/2006

Just for clairification,  the BOTranslation collection should no longer be used,  right?

There is nothing wrong with using the BO Translation collection whatsoever.  However, there may be times that it may work better for you to use the shared data table property.  But the BOTranslations collection can still be used and is in fact something I use often.

The only thing that is shared is the DataTable, NOT the bussiness object and it properties like the BOTranslation did?

Correct.  When you use a shared data table the business objects are two different instances unlike the BO Translations.  When you use the BOTranslations the actual business object referenced in both locations becomes the same instance.

BO Properties (includeinformadd, includeinformedit... etc) need to be set on both business objects to function correctly?

For most cases you are correct...but just keep in mind that there may be a need to set the properties on both since the shared data table shares ONLY the data table used within the BO and not the properties since they are two separate instances.

BTW...I am sorry it took so long to respond.  I just noticed that this item was overlooked somehow Blush

By Scott - 10/19/2006

Not a problem,  Thanks for the clairfication.

Scott

By Trent L. Taylor - 10/20/2006

No problem...I am just glad that I saw the post!