在单个事务范围内,我试图将数据保存到两个单独的 Raven 数据库(在同一个 Raven 服务器上)。
但是,第二个会话中的更改不会保存到服务器。
这是我正在使用的代码:
var documentStore = new DocumentStore { Url = "http://localhost:8081/" };
documentStore.Initialize();
documentStore.DatabaseCommands.EnsureDatabaseExists("database1");
documentStore.DatabaseCommands.EnsureDatabaseExists("database2");
using (var ts = new TransactionScope(TransactionScopeOption.RequiresNew))
{
using (var session1 = documentStore.OpenSession("database1"))
{
session1.Store(new Entity {Id = "1"});
session1.SaveChanges();
}
using (var session2 = documentStore.OpenSession("database2"))
{
session2.Store(new Entity {Id = "2"});
session2.SaveChanges();
}
ts.Complete();
}
我可以看到session1
保存到的database1
更改,session2
但未保存到的更改database2
。我尝试过使用 RavenDb build 992 和 build 2360
根据 Raven 文档,支持跨数据库的事务。
我怎样才能得到session2
要提交的更改?