Subsonic-如何使用SQL架构/所有者名称作为名称空间的一部分? [英] Subsonic - How to use SQL Schema / Owner name as part of the namespace?

查看:100
本文介绍了Subsonic-如何使用SQL架构/所有者名称作为名称空间的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Subsonic 2.2,到目前为止给人留下了深刻的印象-认为它将为我节省一些严肃的编码时间.

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.

在当前数据库(SQL2008数据库)中,我已按架构/所有者名称将表,视图,sps等拆分为单独的块,因此所有客户表都在客户中.模式,产品中的产品.模式等,因此要从客户地址表中进行选择,我会从customer.address中进行选择*

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

不幸的是,Subsonic忽略了架构/所有者名称,只给了我基本表名称.这很好,因为我在架构之间没有重复项(例如,Customer.Address和Supplier.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.

理想情况下,我希望能够按架构/所有者更改名称空间-我认为这对SubSonic的影响最小,但使结果代码更易于阅读.

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.

问题是,我已经在Subsonic的源代码中爬行了,并且不知道如何执行此操作(这无助于我在VB中编写代码而不是C#=是的,我知道,怪ZX Spectrum !!)

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,

谢谢.

Ed

推荐答案

我也将建议使用多提供程序方法. 但是,许多管道已经在超音速方面寻求所有权. 如果在CS_ClassTemplate.aspx中编辑几行,则可以为每个所有者配置文件创建一个名称空间.在第58行(我正在使用v2.1)周围更改为

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

namespace <%=provider.GeneratedNamespace%><%=owner%>

所有者在哪里

string owner = "." + tbl.SchemaName;
if(owner == ".dbo")
  owner = "";

将其放在第14行上方.这样,您可以为每个所有者提供一个名称空间,例如: Northwind.Suppliers,Northwind.Customers等 我将dbo保留为Northwind,因此所有测试都可以进行编译,而无需进行大量编辑. 我运行了一个简单的选择查询,我认为它将按您想要的方式工作.

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.

这篇关于Subsonic-如何使用SQL架构/所有者名称作为名称空间的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆