toptensoftware/PetaPoco — pull request #107 by cjrandolph (2012-03-23 13:49:38+00:00)
Title: Replace column names that conflict with CSharp keywords automatically

When generating models from legacy databases I often see column names that conflict with C# keywords. Since keywords cannot be property names the build will fail when this happens. Currently to correct this the options are to rename the column name in the database or manually updating the database.tt file with a series of tables["tablename"]["columnname"].Ignore or .PropertyName = "Non-ConflictingName" annotations.

To address this I added a check in the CleanUp function to replace C# keywords by appending "_kwr" to the property names when a match is found. _kwr is for KeyWord Replacement, but this could be any arbitrary string.

While it is unlikely that we will see tables with column names such as uint or stackalloc, words such as operator, event, default, private and interface seem to come up all the time.