How-to: Use Microsoft SQL Server CLR Functions and Functions in your CodeSmith Generator Templates Tuesday, December 28 2010
In a previous article, I had mentioned that we added support for Microsoft SQL Server CLR Stored procedures and Functions in the release of CodeSmith Generator 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.
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.