0

我刚刚用 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()。

4

1 回答 1

0

Bob Horn,您使用的是什么版本?我们最近改进了分片支持。我们现在支持 linq 分片,以及创建索引。

于 2012-04-14T14:56:39.910 回答