gpt4 book ai didi

.net - NHibernate:在没有数据库链接的不同服务器上跨多个数据库映射实体

转载 作者:行者123 更新时间:2023-12-03 17:59:20 25 4
gpt4 key购买 nike

使用最新版本的 NHibernate(可能还有一些插件),是否可以在没有数据库链接的情况下跨不同服务器上的多个数据库映射实体?

对于背景,我希望实现与此 DBA.SE post 中描述的内容大致相似的内容。 .

最佳答案

我有一个 interesting answer 在 nhusers 邮件列表中。摘录如下:

From Jason Meckley

[...] if you are talking about storing a single entity across multiple databases, the answer is not cleanly. you might be able to do something with custom user types and/or event listeners to hydrate the object, but that would be a mess to maintain.

A different approach is to transfer the data from one db to another using an ETL process. similar to replication, but only transferring the data required by the other database. you end up with 1 writable database and many read databases. then you map the domain to a single database.

Another option is to determine why there are multiple databases. if they represent different types of data/objects then explicitly express this in the domain. for example CustomerWithAddress is a different entity than CustomerOrder. If you need information from both, then query each database individually and build up a projection in code.

var x = session1.get(id);
var y = session2.get(id);
return merge(x, y);

关于.net - NHibernate:在没有数据库链接的不同服务器上跨多个数据库映射实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5246226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com