在oracle和ms sql server之间共享activerecord类
我的 Castle ActiveRecord 类中有 Oracle 的主键序列:
[PrimaryKey(PrimaryKeyType.SeqHiLo, "UserId", SequenceName = "users_seq")]
public int Id { get; set; }
现在我需要配置 ActiveRecord 以使用 Sql Server,但它不支持序列,但这是不可能的,因为使用了 Oracle 特定的映射。
我不关心身份生成算法,我只是希望它能够工作,那么是否可以为身份字段提供通用映射,以便这些类可以在sql server和oracle之间共享?
I have primary key sequence for oracle in my Castle ActiveRecord class:
[PrimaryKey(PrimaryKeyType.SeqHiLo, "UserId", SequenceName = "users_seq")]
public int Id { get; set; }
Now i need to configure ActiveRecord to use Sql Server, but it does not support sequences, but it's not possible, since oracle-specific mapping is used.
I don't care about identity-generation algorithm, i just want it to work, so is it possible to provide a general mapping for identity field, so the classes could be shared between sql server and oracle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 PrimaryKeyType.Native - 它会根据数据库自动在 SeqHiLo 和 HiLo 之间进行选择。
查看文档了解其他策略 -其中大多数是独立于数据库的。
You can use PrimaryKeyType.Native - it automagically chooses between SeqHiLo and HiLo depending on the database.
Have a look at the docs for other srategies - most of them are database-independent.