| Author |
Message |
yzguy
Joined: 09 Feb 2010 Posts: 18
|
Posted: Tue Feb 09, 2010 2:13 am Post subject: how to get to individual script from differences object |
|
|
How do I get to the script for each of the objects in each db from a Differences object?
I found a round about way to get to the stored procedures, looking up each one by name through the data base object
_differences[100].ObjectIn1.Database.StoredProcedures["dbo", "sp_name"].Text
above is assuming the 100 index is an sp with the name "sp_name", but really the index I use there does not matter, because it is just getting to the db, it is really looking it up by name. I assume there is a way to get to the scipt object directly from the differences instance. Something like:
_differences[100].ObjectIn1.ScriptText
or if there is not a more direct way of getting the script text, how do I get the complete create table script (I could live with the round about method for getting SP scripts, but don't see any way to get the complete table scripts)? something like this?
_differences[0].ObjectIn1.Database.Tables["dbo", "test"].?? |
|
| Back to top |
|
 |
Michelle Taylor
Joined: 30 Oct 2006 Posts: 522 Location: Red Gate Software
|
Posted: Tue Feb 09, 2010 12:20 pm Post subject: |
|
|
You're probably looking for the ScriptObject method? There's one on anything that inherits from ScriptableDatabaseObject, which should be everything you're looking at there.
You can also create a Work object and use the Work.ScriptObject method. |
|
| Back to top |
|
 |
yzguy
Joined: 09 Feb 2010 Posts: 18
|
Posted: Tue Feb 09, 2010 11:20 pm Post subject: |
|
|
I found this:
Work work = new Work();
// Retrieve the script for a particular table
Regions regions = work.ScriptObject(_differences[0].ObjectIn1.Database.Tables["dbo", "acct"], o);
string tmp = regions.ToString();
but the question still remains, is there a more direct method from the differences object to get the indvidual scripts? |
|
| Back to top |
|
 |
yzguy
Joined: 09 Feb 2010 Posts: 18
|
Posted: Tue Feb 09, 2010 11:23 pm Post subject: |
|
|
| I found the script objects in Work, but not anywhere else usefull. I was trying to find the scripts directly without having to pass in the names, or some other reference. I thought they might be in the differences object that I get back after doing a compare. I can loop through the differences object and see individual differences and find out things like the typ of object, name, if they were the same, different or only existed in one or the other db, but I don't see a way to directly access the script from there. Only to take the name from there and then go to the db object using the name, to get the script. This is not a big deal, I just figured if it was in the differences object I'd use that one (I figured that would be faster) |
|
| Back to top |
|
 |
Michelle Taylor
Joined: 30 Oct 2006 Posts: 522 Location: Red Gate Software
|
Posted: Wed Feb 10, 2010 1:26 pm Post subject: |
|
|
You can get the database object from the ObjectIn1 / ObjectIn2 properties of the Difference object, but you'll have to cast it to the right object type (or just casting it to ScriptableDatabaseObject may work) in order to access the ScriptObject method, as it isn't in the IDatabaseObject interface.
You should also be able to use the ScriptObject method in Work directly on the ObjectIn1 / ObjectIn2 objects rather than having to go through the Database property. |
|
| Back to top |
|
 |
yzguy
Joined: 09 Feb 2010 Posts: 18
|
Posted: Sat Feb 13, 2010 12:15 am Post subject: |
|
|
yeah, that worked (the objectin1 and 2)
Thanks |
|
| Back to top |
|
 |
|