Question

From a ColumnSchema object in CodeSmith 6, I need to be able to generate a SQL Server table definition. I'm having trouble generating the types; I need to be able to generate the following types:

varchar(100)
varchar(MAX)
int
bit
etc...

But I can't find a property for this. Is there something in codesmith to extract this? I've been searching but can't find anything...

Thanks.

Was it helpful?

Solution

You can easily create these values by having your template inherit SqlCodeTemplate. Then you would just pass the ColumnSchema object to the GetSqlParameterStatement method which will return this type information.

I'd highly recommend taking a look at the Database\DbSnapShot\TableSchema.cst and StoredProcedures\StoredProcedures.cst templates as they both show insight / or do what you are looking for.

Thanks

-Blake Niemyjski

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top