DataObjects.NET 可以支持 SQL 标识列吗?
虽然 DataObjects.NET 有很多值得喜欢的地方,但我发现帮助资源很精简,并且找不到使用 DataObjects.NET 与 RDBMS 生成的主键的单独示例。看起来 D4O 不会对 SQL Server 进行插入,除非它控制了键。
有人在野外解决过这个问题吗?
While there's lots to like about DataObjects.NET, I've found help resources to be a lean, and can't find a solit example of using DataObjects.NET with RDBMS generated primary keys. It would seem as though D4O won't do inserts against SQL Server unless it's in controll of the key.
Has anyone solved this in the wild?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有简单的方法可以让 DO4 使用 IDENTITY 列 - 主要是因为它被设计为依赖于批量密钥生成(又名 HiLo 算法)。
AFAIK,这里没有好的解决方法。例如,DO4 支持自定义密钥生成器,但开发依赖于 IDENTITY 列的密钥生成器非常复杂 - 事实上,它应该批量插入假记录并进一步删除它们(或回滚事务)才能工作。考虑到可能存在具有唯一约束的列,任务变得相当复杂。
我们将来会考虑实施这一点。
There is no easy way to make DO4 use IDENTITY columns - mainly, because it is designed to rely on bulk key generation (aka HiLo algorithm).
AFAIK, there are no good workarounds here. E.g. DO4 supports custom key generators, but it's pretty complex to develop one relying on IDENTITY column - in fact, it should insert fake records in bulks and remove them further (or rollback a transaction) to work. Taking into account there can be columns with unique constraints, the task becomes pretty complex.
We'll think about implementing this in future.
您可以像这样使用 Key 属性:
更多信息:https: //help.dataobjects.net/#DataObjects.Net%20v5.0/06-Keys.html
You can use Key attribute like this:
More info: https://help.dataobjects.net/#DataObjects.Net%20v5.0/06-Keys.html