Subsonic 生成无主键的表
我需要生成一个没有主键的表。表没有主键是绝对必要的。请帮忙。
I need to generate a table without primary key. Its absolutely neccessary that the table dosen't have primary key. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 SubSonic 来说,表中包含主键是绝对必要的:)
以下引用自 SubSonic 文档中关于约定的内容:
It is absolutely necessary for the SubSonic that table contains primary key:)
The following is quoted from the SubSonic docs on conventions:
有什么理由不能使用序列之类的东西吗?
编辑:我写这个的方式有点愚蠢,因为一旦你重新启动应用程序。你会得到重复的键..你应该使用数据库提供的序列。对此感到抱歉。
Is there any reason you cannot use something like sequences?
EDIT:The way I wrote this was kinda dumb because once you reboot the app. you'll get duplicate keys.. You should use a sequence provided by the DB. Sorry about that.
正如亚当指出的那样,这是不可能的。老实说,我想不出有什么情况(在 OLAP 之外)不能进行 PK。或者也许你陷入了遗留问题——我可以挖掘这一点。
正如您所指出的,您可以做的就是使用我们的查询器工具来解决这个问题,然后您可以将结果发送到List<>。更新应该以同样的方式工作 - 但不确定插入。
as Adam pointed out this isn't possible. To be honest I can't think of a situation (outside OLAP) where you can't have a PK. Or perhaps you're stuck in a legacy situation - I can dig that.
What you can do to get around it is, as you pointed out, use our querier tools and then you can send the results ToList<>. Updates should work the same way - not sure about inserts though.