How Change TableSchema Programatly ?


Author
Message
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (652 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
I believe Trent already has it on the list of Enhancements for our next BO Mapper update Smile. I'll confirm that with him and let you know once I have a more concrete idea of the ifs and whens.
Chris Diesel
Chris Diesel
StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)
Group: StrataFrame Users
Posts: 74, Visits: 300
Thanks for looking!  Is this something you guys would consider changing?  Maybe make the base property so it's read/write, doesn't have to be overridden and set the default value in the constructor?
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (652 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
You're right, this does at present require the manual step of removing the table schema from the designer file whenever you build the BO mapper. Once it is removed, you can set the table schema as an overridable property on the BO itself (or the base BO) to handle it from there.
Chris Diesel
Chris Diesel
StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)StrataFrame User (126 reputation)
Group: StrataFrame Users
Posts: 74, Visits: 300
I know this is an old thread, but I have just come across the need to override the TableSchema property too, but I'm confused.  How can I override this property in a base level class when it's being overridden at a higher level in each business object's designer code?  Doesn't this just override my base class code then? Ermm  Thanks!
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Perdo,



I think they are suggesting that in your BaseBO (if you aren't using one, now would be the time), you override the TableSchema property. Within it, you would then code the logic to change the db schema based on company. You could go about getting the company within the TaleSchema property in a number of ways. You would also add a company property to the BaseBO, or you could have a shared class that provide the current company info...I'm sure there are other ways too. Does that make more sense?
Elio Reyes
Elio Reyes
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 46, Visits: 251
Excellent information, I know that I asking so much, I have VB concept problem, because I need to change the Schema in runtime, I was thinking in a global variable, but I don’t know how to this, is the way that I found to change the schema when the user change the company running the application.



Any suggestion is appreciate



Thanks a Lot for your time and your very important information



SF

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Pedro Hernández (12/04/2008)
Hi

I'm sorry for my bad exexplanations

my problem is with SF internals instructions like save(), BrowseDialog..... because I can't tell then wichwhichema use, And of course they use the one when I make with the Business Object Mapper.

Your explanations are OK, but it looks like you are not reading the replies properly Hehe, the answer is right there for you, by working with the TableSchema property.

Edhy Rijo

Elio Reyes
Elio Reyes
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 46, Visits: 251
Hi



I'm sorry for my bad exexplanations



I fill the Bo's nice, because I send then a parameter with the Schema, my problem is with SF internals instructions like save(), BrowseDialog..... because I can't tell then wichwhichema use, And of course they use the one when I make with the Business Object Mapper.



I need to change this too.



Thanks SF
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Pedro Hernández (12/04/2008)
Sorry it works, the problem is when I save usisng the save method bo.save()

Pedro,

Probably there are some methods in SF which will use the TableSchema property of the BO, and in your code you are not updating this property, then it will return the schema of the table which was selected at the time of the BO generation by the BOM.

Like I said before, in your base BO class, simply override that property to return the value of your custom schema, something like this:

Public Overridable ReadOnly Property TableSchema()

     Get

          Return GetCustomSchemaName()

     End Get

End Property

Private Function GetCustomSchemaName() As String

     '-- Add your logic here to return your Schema Name from your source.

     Return "Your Schema Name"

End Function

Or if you want to make is simpler, don't create the GetCustomSchemaName() function and add that logic in the "Get" of the TableSchema property.  If you don't have a base BO, then you will need to do the same for all the BO you create, so it is a best practice to have your own base BO class.

And in your Fill command try to use the propertys of the BO available to you like the TableSchema, so your method may look like this:

Public Sub FillAll()

     Me.FillDataTable("SELECT * FROM " & Me.TableSchema & ".OP_OPER_DET_MO WHERE ORDEN_PRODUCCION IN " & _

" (SELECT ORDEN_PRODUCCION FROM " & Me.TableSchema & ".ORDEN_PRODUCCION WHERE ESTADO='L' ) AND OPERACION = 'GALERA' ORDER BY ORDEN_PRODUCCION")

End Sub

Of course, I have not try the above, it is mean to give you an idea to explore.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, if you are going to take a base level approach, then you need to create a BaseBO that all of your BOs inherit from instead of directly inheriting from BusinessLayer.  Then you could implement core base logic to redirect the table schema.  Since I don't really know what you are trying to do, I can't give you a straight answer here.  You are talking about a 3rd party database.  So are you creating your own DbDataSourceItem or trying to make an existing one work?  If you are trying to talk to a 3rd party database then I would recommend creating your own DbDataSourceItem that has all of the this logic within it.  If the logic for this database is closest to SqlServer, the copy over the SqlDataSOurceItem class and start from there.  If it is closest to OLEDB the copy over the Vfp ro AccessDataSourceItem and do the same. 

I really don't have enough information to give you any direct answers, but maybe some of these ideas will get you going in the right direction depending upon your needs.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search