【问题标题】:Table and Column names causing problems导致问题的表和列名称
【发布时间】:2009-09-11 09:23:27
【问题描述】:

当 T4 linq 模板使用 subsonic 3 为我的 MySql db 生成类时,我遇到了问题。

看起来我们的表名之一“operator”导致 Context.cs 生成的类出现问题。在 Context.cs 的以下代码行中,Visual Studio 将 <operator> 视为 c# 运算符并生成“预期类型”的编译错误

public Query<operator> operators { get; set; }

有没有我可以解决这个问题而不必重命名我的数据库表和列名?例如,在 Settings.ttinclude 中对某些内容进行硬编码以使用或将不同的名称映射到特定的数据库表和列?

【问题讨论】:

    标签: subsonic naming operator-keyword


    【解决方案1】:

    CleanUp() 函数就是为此而构建的——它位于 Settings.tt 中。您应该能够根据需要重命名您的课程。

    【讨论】:

    • 谢谢罗伯。我在 CleanUp() 函数中添加了一条 if 语句,如下所示: //把你的逻辑放在这里... if (tableName.Equals("providers")) result = "providersTable";希望 tableName "providersTable" 将与 "provider" 相对使用。虽然没有快乐..我还有其他事情要做吗?在模板类的生成过程中是否会自动调用 CleanUp()?
    • 在此页面上的 cmets blog.wekeroad.com/subsonic/subsonic-3-0-preview-2 中找到了一个很好的示例,用于添加 CleanUp() 函数和 Settings.ttinclude。在页面中搜索 bbqchickenrobot 的 cmets。
    猜你喜欢
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 2020-09-04
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多