In a previous post I had mentioned that we added SQL CLR Stored procedures as well as SQL Functions in the release of CodeSmith 5.2. Since then there has been a few questions since then on how to add this to your existing templates. The great news is, you can add the functionality in a few easy changes.
Related Articles
To enable SQL function support you need to set IncludeFunctions="True" on any types inheriting from SchemaObjectBase (E.G. CommandSchema, CommandSchemaCollection, DatabaseSchema...).
Once this has been done you will see SQL functions be added to your User Interface Command pickers as well as show up in the API like DatabaseSchema.Commands.
How do I check to see what type of SQL Function it a command is?
- CS_IsCLR: Returns true if the command is a CLR Procedure.
- CS_IsScalarFunction: Returns true if the command is a Scalar Function.
- CS_IsTableValuedFunction: Returns true if the command is a Table-Valued Function.
- CS_IsInlineTableValuedFunction: Returns true if the command is a Inline Table-Valued Function.
- CS_IsMultiStatementTableValuedFunction: Returns true if the command is a Multi-Statement Table-Valued Function.