如何使用 SubSonic 3 检索表名?

发布于 2024-10-04 05:06:34 字数 228 浏览 0 评论 0原文

很好的 SubSonic 2 我能够检索我正在查询的表的名称:

.Schema.TableName

现在我切换到 SubSonic 3 我找不到任何方法来实现相同的目标。

我倾向于避免在 che 源代码中对表的名称进行硬编码,因此如果我更改它,编译器会抛出异常。

(注意:是的,我对大多数查询使用新的“类似 linq”语法,但我处理的是复杂的查询,我认为最好遵循旧的方式)。

Whit ol' good SubSonic 2 I was able to retrieve the name of the table I was querying:

.Schema.TableName

Now that I switched to SubSonic 3 I can't find any way to achieve the same goal.

I tend to avoid to hardcode the name of the table in the che source code, so if I change it the compiler throw me an exception.

(Note: yes, I'm using the new 'linq-like' syntax for most of the queries, but I dealing with a complex one and I think is better to follow the old manner).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪你到最终 2024-10-11 05:06:35

将以下内容放入 structs.tt 中,您就可以使用表格准备好 Tables 类。你可以像subsonic 2.0那样使用它,即Table.TableName。

 public class Tables
       {
           <#  foreach(var tbl in tables){
            if(!ExcludeTables.Contains(tbl.Name))
            {
            #>
                public static string <#=tbl.CleanName#> = "<#=tbl.Name#>";
            <#
            }
            }
            #>
       }

Put following into structs.tt and you have Tables class ready with tables. You can use it like subsonic 2.0 that is Table.TableName.

 public class Tables
       {
           <#  foreach(var tbl in tables){
            if(!ExcludeTables.Contains(tbl.Name))
            {
            #>
                public static string <#=tbl.CleanName#> = "<#=tbl.Name#>";
            <#
            }
            }
            #>
       }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文