Bill Fellows shows off some C# skills that he uses to build table definitions inside Biml:
Good grief, that’s a lot of code, how do I use it? The basic usage would be something like
<Tables> <#= GetAstTableNodeFromQuery(this.RootNode.OleDbConnections["msdb"], "SELECT 100 AS demo", "dbo", "DemoQuery").GetBiml() #> </Tables>The call to GetAstTableNodeFromQuery return an AstTableNode which is great, but what we really want is the Biml behind it so we chain a call to
.GetBiml()
onto the end.What would make that better though is to make it a little more dynamic. Let’s improve the code to create tables based on a pairs of names and queries. I’m going to use a Dictionary called namedQueries to hold the names and queries and then enumerate through them, calling our GetAstTableNodeFromQuery for each entry.
Read on for the underlying code. Bill also promises to refactor this code and make it more versatile.