Question

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.

Was it helpful?

Solution

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);
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top