views:

28

answers:

1

This doesn't make much sense to me. We had this happen twice recently when generating SubSonic objects for a database table or view columns got renamed to ColumnX. The first time it made sense because the column name is Value, a C# keyword. But the second time it happened, the table's column name is Grade, which is not a keyword or reserved word. Does anyone know why SubSonic turns this column name into GradeX when it generates objects?

Thanks.

A: 

It is, like you assumed, to replace words so they don't conflict with .Net or SQL types. Don't forget SubSonic talks to various db providers so although "Grade" isn't a MSSQL type it's possible it's an Oracle or MySQL etc...

Under SubSonic.Utilities.Utility is a method named KeyWordCheck which does the appending.

Perhaps you can compile your own version and amend this method to exclude "Grade":

  public static string KeyWordCheck(string word, string table, DataProvider provider)
        {
            string appendWith = "X";
            if (provider.AppendWith != string.Empty)
                appendWith = provider.AppendWith;

            return KeyWordCheck(word, table, appendWith);
        }
DaveHogan
Thanks, that is very useful information about this function. Something I forgot to mention originally is that the table containing the Grade column is named grades itself. So my theory is that since SubSonic makes the row names singular, the Grade column got changed into GradeX so it didn't conflict with the table itself.
Evan Lynch