Subsonic - 如何使用 SQL 架构/所有者名称作为命名空间的一部分?
我刚刚开始使用 Subsonic 2.2,到目前为止印象深刻 - 认为它会节省我一些认真的编码时间。
在我开始全职使用它之前,尽管有些事情困扰着我,我想解决一下。
在我当前的数据库(SQL2008 数据库)中,我已按架构/所有者名称将表、视图、sps 等拆分为单独的块,因此所有客户表都在客户中。 架构,产品中的产品。 架构等,因此要从客户地址表中进行选择,我会从 customer.address 中执行 select *
不幸的是,Subsonic 忽略架构/所有者名称,只提供基表名称。 这很好,因为模式之间没有重复项(例如 Customer.Address 和 Supply.Address 并不同时存在),但我只是觉得如果可以按模式拆分,代码会更清晰。
理想情况下,我希望能够通过模式/所有者更改命名空间 - 我认为这对 SubSonic 的影响最小,但使生成的代码更易于阅读。
问题是,我已经爬遍了 Subsonic 源代码,但不知道如何做到这一点(我用 VB 编码而不是 C# 没有帮助 = 是的,我知道,归咎于 ZX Spectrum!
)之前解决过这个问题或者知道如何解决它,我将非常感激,
提前致谢。
埃德
I've just started using Subsonic 2.2 and so far very impressed - think it'll save me some serious coding time.
Before I dive into using it full time though there is something bugging me that I'd like to sort out.
In my current database (a SQL2008 db) I have split the tables, views, sps etc. up into separate chunks by schema/owner name, so all the customer tables are in the customer. schema, products in the product. schema etc., so a to select from the customers address table i'd do a select * from customer.address
Unfortunately, Subsonic ignores the schema/owner name and just gives me the base table name. This is fine as I've no duplicates between schemas (e.g Customer.Address and Supplier.Address don't both exist) but I just feel the code could be clearer if I could split by schema.
Ideally I'd like to be able to alter the namespace by schema/owner - I think this would have least impact on SubSonic yet make the resulting code easier to read.
Problem is, I've crawled all over the Subsonic source and don't have a clue how to do this (doesn't help that I code in VB not C# = yes I know, blame the ZX Spectrum!!)
If anyone has tackled this before or has an idea on how to solve it, I'd be really grateful,
Thanks in advance.
Ed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(4)
您可以尝试执行具有相同底层数据库连接的单独提供程序,如下所示:
<SubSonicService defaultProvider="DBData">
<providers>
<clear/>
<add name="DBData" type="Subsonic.SqlDataProvider, SubSonic" connectionStringName="LocalSqlServer" generatedNamespace="DBData" includeTableList="table_a,table_b" spStartsWith="app,get,set" viewStartsWith="v_" />
<!--CMS Provider-->
<add name="CMS" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="LocalSqlServer" generatedNamespace="CMS" stripTableText="CMS_" includeTableList="CMS_Content,CMS_Page" useSPs="false"/>
</providers>
</SubSonicService>
我认为您不能以这种方式使用架构本身作为键,但您至少可以结合使用 includeTableList 和生成的命名空间。 您说不同模式之间没有重复的表名,因此它可能会起作用。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我也打算建议采用多提供商方法。
但许多管道已经处于亚音速状态。
如果您在 CS_ClassTemplate.aspx 中编辑几行,您可以为每个所有者配置文件创建一个命名空间。 将第 58 行(我使用的是 v2.1)更改为
所有者所在的位置
您将其放在上面第 14 行附近。这样您就可以为每个所有者拥有一个命名空间,例如:
Northwind.供应商、Northwind.客户等
我将 dbo 保留为 Northwind,因此所有测试都无需进行大量编辑即可编译。
我运行了一个简单的选择查询,我认为它会按照您想要的方式工作。
I was going to suggest the multiple provider approach too.
But a lot of the plumbing is already in subsonic for ownership.
If you edit a couple of lines in CS_ClassTemplate.aspx you can create a namespace for each owner profile. Change around line 58 (I'm using v2.1) to
where owner is
You put that up above, around line 14. This way you can have a namespace for every owner like:
Northwind.Suppliers, Northwind.Customers, etc.
I left dbo as just Northwind so all the tests would compile without a lot of editing.
I ran a simple select query and I think it will work the way you want.