Search code examples
c#sql-serversmo

What does the method "InitTableColumns" of the "Database" class in the "Microsoft.SqlServer.Management.Smo" library do?


In the "Microsoft.SqlServer.Management.Smo" nuget package there's a "Database" class which has a "InitTableColumns" method. As any method in said library this one hasn't got a summary. More bizzare is that there isn't ANY mention of in it The Internet (yes, seriously).

Especially the MSDN Database class page.

So, does anyone know what it does?


Solution

  • Generally speaking undocumented methods are best avoided :)

    If you want to decompile it you can use a program like DotPeek (from JetBrains) or ILSpy.

    Once the decompiling program is installed, you need to find the dll that you want to decompile. Decompiling will take the compiled .NET code and convert it back into C# that should be easier to read (note that is not always the case).

    Finding the dll is easy, you either pull it from the bin folder of the compiled code, or you can browse find the path to it by finding the dependency Microsoft.SqlServer.SqlManagementObjects in the VS solution explorer drop-down, right-clicking on the dependency, clicking "properties", and copying the path that shows in the property window.

    Now that you have the path to the dll, you use the decompiler to open the dll at that path and decompile it. Once decompiled, the decompiler program will let you browse the namespaces, classes, and methods contained in the dll.

    this is what it shows me about InitTableColumns()

    public void InitTableColumns()
    {
        this.InitChildLevel((Urn)"Table", (ScriptingPreferences)null, false);
        this.InitChildLevel((Urn)"Table/Column", (ScriptingPreferences)null, false);
    }
    

    Which then leads me on a wild goose chase through the code trying to understand how this library is implemented!