Test the final result

Now that you've written the template, test it.

  1. Build the template so that CodeSmith Generator shows the right properties in the Properties window. Click Build on the toolbar or press Ctrl+Shift+B. If the template has no errors, the Output window shows progress messages like these:

    ---------------- Compile started -----------------
    Build complete -- 0 errors, 0 warnings
    ---------------------- Done ----------------------
    Compile succeeded
    

    If the template has errors, they appear in the Output window.

  2. In the Properties window, set the three enumerated properties: ExecuteAs, IsolationLevel and JsonMode. Generator shows a drop-down list of the valid choices for each one.

  3. Click the SourceTable property value, then click the builder button (...) to open the Table Picker dialog.

    Table Picker dialog with a Data Source drop-down list and a list of tables

  4. Select the data source, and the table in that data source to use with the template. To create a new data source, click the builder button next to Data Source.

  5. Click Select to return to the editor.

  6. Click Generate on the toolbar or press F5 to run the template. Generator generates the output and shows it so you can save or copy it.

  7. Run the generated script against the database (for example, in SQL Server Management Studio), then run the procedure, such as EXEC Person.GetAddressTypeJson, to see the table as JSON.

Learn more