开发者

SubSonic generation of tables with columns as ColumnX

开发者 https://www.devze.com 2023-01-13 16:48 出处:网络
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

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 keywor开发者_如何学编程d or reserved word. Does anyone know why SubSonic turns this column name into GradeX when it generates objects?

Thanks.


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);
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消