【问题标题】:Ravendb 4 - Create Index ProgrammaticallyRavendb 4 - 以编程方式创建索引
【发布时间】:2019-01-15 13:00:27
【问题描述】:

如何在 RavenDb 4 中为特定数据库添加索引。我看到了函数

new SearchableIndex().Execute(_documentStore);

如何指定数据库,而不将默认数据库设置为文档存储初始化的一部分。我希望将数据库名称作为参数传递。

【问题讨论】:

  • 一种方法是设置.Database 属性_documentStore。不确定这是否是最好的方法。但它有效。
  • 你必须文件存储。您可以在自己的函数中接受数据库名称参数,然后使用该数据库创建一个文档存储并针对该文档存储执行索引。

标签: ravendb ravendb4


【解决方案1】:

您使用Database 属性为DocumentStore 设置数据库。初始化时,这样做:

var _documentStore = new DocumentStore
{
    Urls = new[] { "http://localhost:8080" },
    Database = "databaseName"
};

new SearchableIndex().Execute(_documentStore);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 2019-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多