Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

The OnPostRender event is fired after CodeSmith Generator has merged metadata with your template to produce the output. You can use this event to perform any additional processing you would like after CodeSmith Generator has finished its job. For example, the StoredProcedures.cst sample template included with CodeSmith Generator uses this event to autoexecute the generated SQL script:

protected override void OnPostRender(string result)
{
    if (this.AutoExecuteScript)
    {
        // execute the output on the same database as the source table.
        CodeSmith.BaseTemplates.ScriptResult scriptResult = CodeSmith.BaseTemplates.ScriptUtility.ExecuteScript(
            this.SourceTable.Database.ConnectionString,
            result,
            new System.Data.SqlClient.SqlInfoMessageEventHandler(cn_InfoMessage));

        Trace.Write(scriptResult.ToString());
    }

    base.OnPostRender(result);
}
  • No labels