SubSonic 3 和多个 PK 列
我在使用 SubSonic 3 和多个主键列时遇到问题。 ActiveRecord T4 脚本似乎不支持它。
在 Settings.ttinclude 的第 173 行中,
return this.Columns.SingleOrDefault(x=>x.IsPK) ?? this.Columns[0];
它尝试获取单个主键列并失败。
有什么解决办法吗?
I'm having problem with SubSonic 3 and multiple Primary Key columns. It seems like it isn't supported via the ActiveRecord T4 script.
In line 173 of Settings.ttinclude
return this.Columns.SingleOrDefault(x=>x.IsPK) ?? this.Columns[0];
It tries to get a Single Primary Key Column and failed.
Any solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我相信 EntitySpaces 确实支持它们。
我的 2cents
--- 这是对 womp 的回答,只是想说 NHibernate 并不是唯一众所周知的支持组合键的 ORM。 至少在投反对票时留下评论(或侮辱:p)——
I believe EntitySpaces does support them.
My 2cents-
-- this was intented to be an answer to womp just to say that NHibernate isn't the only well known ORM supporting composite keys. At least leave a comment (or an insult :p ) when downvoting --
您可能会创建一个视图,该视图通过连接复合键列来创建主键。 例如,如果它们是 varchar 列 PK = COALESCE(K1, '|', K2, '|', K3)。 如果它们是数字,您可以通过将每个键列乘以乘数来创建唯一的 PK 来执行类似的操作。
You could potentially create a view which creates a primary key by concatenating the composite key columns. e.g. if they're varchar columns PK = COALESCE(K1, '|', K2, '|', K3). If they're numeric, you could do something similar by multiplying each key column by a multiplier to create a unique PK.
我将调整模板以在将来添加对此的支持(因为很多人都遇到问题),但您可以将其更改
为:(
这是徒劳的),然后将返回类型更改为 Column []。 从这个角度来看,更改应该非常简单,但是您需要从头到尾更改模板。
我知道人们喜欢复合键 - 它们对许多人来说特别重要,但(我认为)我不喜欢这种设计。 一张表(不是很多/很多)应该有一个 PK 来唯一地 ID 一行...
我也明白很多人无法控制这样的事情:)。 不管怎样 - 如果你愿意帮忙并分叉/推送这个,我真的很感激。
I'll tweak the templates to add support for this in the future (since a lot of people are having issues with it) but you can change this:
to this:
(this is free-handed) and then change the return type to Column[]. The change should be pretty simple from this point of view, but then you'd need to change the templates throughout.
I know people like composite keys - and they are particularly important for many/many, but (my opinion) I don't like the design. A table (that's not many/many) should have one PK to uniquely ID a row...
I also understand that many folks can't control such a thing :). Anyway - if you'd like to help and fork/push this, I'd really appreciate it.
许多 ORM 产品不支持复合键,因为这样做非常复杂。 据我所知,NHibernate 是唯一这样做的知名 .Net ORM 产品。
Mindscape 正在讨论对其 Lightspeed 产品第 3 版的复合密钥支持,但我对此了解不多。
SubSonic 目前不支持复合键。
Many ORM products do not support composite keys due to the overwhelming complexity of doing so. As far as I know, NHibernate is the only well-known .Net ORM product that does.
Mindscape was discussing composite key support for version 3 of their Lightspeed product, but I don't know too much about it.
SubSonic does not currently support composite keys.