在oracle和ms sql server之间共享activerecord类

发布于 2024-08-29 05:05:42 字数 335 浏览 4 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌吟 2024-09-05 05:05:42

您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文