I have a legacy database that has column names like "void". I also have several Microsoft SSIS log databases. those have column names like "event" and "operator". It looks like we need to set the CleanName on the column early on in Settings.ttinclude template, but I am not quite sure the best way to tackle this since the list of reserved words might get long. Should this be a separate include? I'd be happy to contribute, but I'd like some design input from you smart people first.
+4
A:
Reserved words in c# can be handled in code by prepending them with the '@' symbol. For example,
public void Test(int if)
{
}
fails with a compiler error, but
public void Test(int @if)
{
var something = @if;
}
is just fine. This works for property names as well. You could probably upgrade your T4 templates to check a list of reserved words, and if there is a match, prepend the '@' symbol in front of the name.
As to the best way of adding this into Subsonic, I'd have to do more digging.
womp
2009-07-31 19:02:47