George J.'s profile“Daily Cycle”PhotosBlogLists Tools Help

Blog


    2/15/2009

    SubSonic v3’s T4 Templates, Part 3

    About a month ago, I created a first version of T4 templates for SubSonic v3 using T4Toolbox. They started as a fun way to learn using T4 transformation. Now, these templates are now intergraded in SubSonic v3 source.

    If you are fan of SubSonic, or not, if you want to learn more about T4 transformation and how to use in a real life application, I suggest you download SubSonic v3 source and give it a try...

    Happy transforming!

    del.icio.us Tags: ,
    1/12/2009

    SubSonic v3’s T4 Templates

    I short post in order to provide Subsonic v3’s T4 templates based on T4Toolbox, and a short demonstration video.

    Starting with the video – play the video in full-screen:

    The templates used for the video can be found in my SkyDrive:

    Finally some short notes about the templates:

    • When I saw the T4 templates that comes with the first SubSonic v3 Alpha, I must say I was scared! I really liked the smooth code generation method Subsonic v2 had. As soon as you drop the T4 templates in your project, error messages start popping from everywhere.
    • Before Christmas I found out T4Toolbox project in CodePlex. I knew nothing about T4 template code generation back then, but it looked like that was the way SubSonic v3 T4 templates should be implemented. Thanks to Oleg Sych weblog posts, and Clarius’ T4 Editor Community Edition, these templates were created. I only wish, I had the Professional version…
    • In order to use the templates in a project, first you have to make sure that your application has a app.config file with connection strings, and the Subsonic.Core.dll referenced. Then you can add the T4Toolbox folder and the SubSonic3 folder in your project. Thanks to T4Toolbox templates’ infrastructure, all the templates are implemented as classes and they don’t make code generation – there are no error produced and no popping error messages.
    • The code generation procedure is initiated from the last file added to the project – SubSonic3Creator.tt has all the information needed to make SubSonic’s classes generation successful. It holds the connection string’s name to the database, the namespace under the classes are generated, as well as the database name for SubSonic’s reference. All the files created are under this template – every time this template is saved, the code generation procedure is initiating.
    • You are free to use the templates in your projects – remember these SubSonic T4 templates are in early stage of developing and may contain errors. In order to avoid T4 template code generation errors you can remove the value, attribute Custom Tool is holding for each template in T4Toolbox and Subsonic3 folders. Only SubSonic3Creator.tt has to maintain the value in the attribute.