SubSonic 3和多个PK色谱柱 [英] SubSonic 3 and multiple PK columns

查看:98
本文介绍了SubSonic 3和多个PK色谱柱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SubSonic 3和多个主键列上遇到了问题。看来ActiveRecord T4脚本不支持它。

I'm having problem with SubSonic 3 and multiple Primary Key columns. It seems like it isn't supported via the ActiveRecord T4 script.

在Settings.ttinclude的第173行中

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.

有解决方案吗?

推荐答案

我将调整模板以在将来添加对此的支持(自很多人对此都有疑问),但是您可以更改此值:

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:

return this.Columns.SingleOrDefault(x=>x.IsPK) ?? this.Columns[0];

为此:

return this.Columns.Where(x=>x.IsPK).ToArray();

(这是徒手的),然后将返回类型更改为Column []。从这个角度来看,更改应该非常简单,但是您需要在整个模板中进行更改。

(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.

我知道人们喜欢组合键-特别是他们对许多人来说很重要,但是(我认为)我不喜欢这种设计。一张桌子(不是很多/很多)应该有一个PK来唯一地标识一行...

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.

这篇关于SubSonic 3和多个PK色谱柱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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