Script object without specifying SQL Object type
gr8nash
Posts: 2
Hi all,
I am working on a migration tool using your awesome API. I am however stuck because every example i can find uses something like:
' Retrieve the script for a particular table
Dim regions As Regions = work.ScriptObject(widgetStaging.Tables(0), Options.Default)
I really would like to NOT have to look up an object type and pass that in. In the command line version there is an option "/Include:ALL" How can i do something similar with SQL Compare API?
I hope that question is clear enough
I am working on a migration tool using your awesome API. I am however stuck because every example i can find uses something like:
' Retrieve the script for a particular table
Dim regions As Regions = work.ScriptObject(widgetStaging.Tables(0), Options.Default)
I really would like to NOT have to look up an object type and pass that in. In the command line version there is an option "/Include:ALL" How can i do something similar with SQL Compare API?
I hope that question is clear enough
Comments
You can script all database objects without knowing the specific type of object using a bit of .NET Reflection magic. It's a matter of getting the list of properties from the Database object and checking to see if they implement SerializableDatabaseObjectCollection and then trying to convert them into individual IDatabaseObject objects from their respective IEnumerable collections. Note I'm not a VB programmer and I can't vouch that the VB version of this works; I had just used a utility to convert it. Here is the original C# code: