StrataFrame Forum

Use one BO for multiple exact tables?

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

By Michael Reese - 2/20/2011

Hi I have a database with multiple tables that are exactely the same but have different names in the same database. Ie. MIC_Segment_PID and GENLAB_Segment_PID. Can I create one BO called Segment_PID and on demand, map it to the  MIC_Segment_PID and GENLAB_Segment_PID tables in the database without creating native BOs for the tables?

Michael
By Trent L. Taylor - 2/21/2011

Option #1
Well, it is possible, but I would recommend creating one BO for each table.  If you are going to have some common logic (i.e. methods, etc) that you want to share, then I would create a base BO that these 4 BOs inherit from.  Next, create 4 BOs and map them so they all get the property descriptors, SPROC mapping, etc. all lined up correctly.  Since they have different names it is easier to do this. 

Option #2
If you want to create a single BO, then you will have to override the TableName property that is generated, along with anything that directly relates to that table name (i.e. sprocs, CRUD settings, etc).  You can then dynamically manipulate the BO for your desired table name.

But the easiest and safest way is to go with Option #1