views:

232

answers:

1

CodeSmith has a nice StringUtils class that can be used to change database object names to singular, plural, camel case, pascal case, etc... Very useful for creating data access layers in their code generation tool.

I'm trying to port some CodeSmith templates to the T4 template files used by Visual Studio, and I'm trying to find a similar library to do these things.

There must be one somewhere in T4, since that's what is used to produce the LINQ to SQL classes, and it does a nice job of pluralization / singularization.

Does anyone know where this library exists, or if a free library with similar functionality exists somewhere?

Thanks!

A: 

I've used both CodeSmith with .netTiers, and more recently T4. I'm not sure as to the specifics of what Linq to SQL uses, but with T4 you can basically do anything you can do in code in the .NET framework.

To that end, why not craft you own StringUtils class (there are plenty of existing, open source projects that provide numerous pre-written method libs), and include these utilities in a external T4 file. You can then include this file as a parent to the child template you are creating. You can use the include directive to do this, like so:

<#@ include file="Utilities.tt" #>
steve_c
Can you point me to one of these numerous pre-written method libraries?
Adam Barney
I think Subsonic has a pretty good one for dealing with pluralized table names, and tables with annoying prefixes. Subsonic is open source too, so I'd assume you could use said methods. I would of course check the license first though.
steve_c