我刚刚用 RavenDB 实现了分片。第一次运行时,代码如下:
tempShardedDocumentStore = new ShardedDocumentStore(new ShardStrategy(), shards);
tempShardedDocumentStore.Initialize();
IndexCreation.CreateIndexes(typeof(RavenDataAccess).Assembly, tempShardedDocumentStore);
...产生此错误:
System.TypeInitializationException:'WriteToRaven.Data 的类型初始化程序。RavenDataAccess' 引发了异常。---> System.NotSupportedException:分片文档存储没有数据库命令。您需要显式使用分片实例来访问数据库命令
首先,ShardedDocumentStore 确实有 DatabaseCommands:
其次,如果那行不通,是否应该这样做?
IndexCreation.CreateIndexes(typeof(RavenDataAccess).Assembly, shards[0]);
如果是这样,现在我的 linq 查询将不起作用:
System.NotSupportedException: Raven.Client.Shard.ShardedDocumentSession.QueryT目前不支持分片 linq 查询
using (IDocumentSession ravenSession = GetRavenSession())
{
return ravenSession.Query<T>().OrderByDescending(orderByClause).FirstOrDefault();
}
我怎样才能让它工作?
注意:GetRavenSession() 从上面显示的分片文档存储中返回 OpenSession()。