TurboTemplate is a fast source code generation helper which quick transforms between your SQL database and some templated text of your choice.
Generation frameworks are very clever but often require messy templates which:
- Integrate with the IDE
- Cover your source code in generative attribute decorations
- Tricky to modify source without partial classing
TurboTemplate offers none of these options. Instead, it passes information from your database to the standard
RazorEngine templating engine. Soon it will also just be able to pass Lists Of Anything™ to the template, thus allowing you to perform transforms on sets of data you’ve defined. This
can be anything from lists of files to columns from a database. It’ll then get steamrollered by Razor, producing some text output.
At the moment, it happily connects to a SQL database and shows lists of stored procedures and their associated parameters. If you wish, it can be
executed too, populating a DataSet with tables containing the output from your procedure.
After this is done, just copy and paste it into your code file. It’s not a proper code gen tool, it’s just designed to
save you typing out 20
INotifyPropertyChanged properties after creating the SQL table.
NOTE: For my project I don’t, and can’t use an ORM. It’s out of choice, it’s just not an option, hence why this templating tool was created.
- Profiles – everything is automatically saved and restored on load
- Standard Razor template syntax
- Template Editor to get the template started with C#/VB.NET syntax highlighting (from the
- Live Template Editor (with immediate updates to generated text) to tweak the template you’ve just used and the option to write it back to the actual template afterwards
- List of Sources to Templates stored with the Profile, can be arranged with move up/move down controls
- Some @Model helpers
- @Model.EnumerateColumns – foreach’s the column names returned by the stored procedure (usually a Get* procedure, returned into @Model.Data DataSet)
- Ability to use prefix/suffix to wrap the column names,
- #NAME injects the column/parameter name
#DATATYPE injects the System.Type.ToString()
#GETFIELD does a similar thing but also works for DbType
- #R(input,replacethis,withthis) does in-string replacement
- @Model.EnumerateParameters – foreach’s the sproc parameters and returns a string
- Exactly the same options as EnumerateColumns
- @Model.ViewBag for Template variables, all serialized using a Dynamic dictionary
- Basic threading during template to content processing using TPL
- Built with standard WinForms controls, with references to ICSharpCode.TextEditor, PIA adodb and MSDASC, and NuGet RazorEngine package
- Implement Lists – a way to just pass in text line-by-line for processing. For example, pasting in a bunch of “this = that” code could be quickly converted to “that = this” using a simple template.
- Add unit tests – yeh, whatever
- Supply a default Profile with Templates, perhaps a Profile import/export
- Add a nice icon, clean up UI
Template Editor (activated by clicking Templates link)
(can be updated from Live Template shown in right hand pane)
(pane orientation can be changed by double clicking splitter)
Showing Razor content mixed with some content helpers I baked into the @Model
Parameter entry for a Create sproc (not usually required)
Parameter entry for GetXXX sproc, usually always required so we have a list of column names.
Also has a place to define any other options like the Entity name.