我注意到,当我向Ravendb添加文档并看到“ Raven-entity-name”元数据时,它使其变得复数。例如,如果我的模型名称是 Product 它将其更改为 Products. 。为什么这样的行为?

如果我创建了一个索引,我被迫使用 docs.Products

有帮助吗?

解决方案

这是Ravendb哲学的一部分,可以在配置上进行惯例,因此默认情况下会这样做。

但是,如果您愿意,您可以覆盖它,可以做这样的事情:

_documentStore = new DocumentStore { Url = "http://localhost:8080/" };
_documentStore.Conventions.FindTypeTagName = t =>
{
    if (t.Name == "MyClass")
        return "MyClassBlahBlah";
    else
        return Raven.Client.Util.Inflector.Pluralize(t.Name); 
};

_documentStore.Initialize(); 

这个线程 在Ravendb讨论小组中获取更多信息

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top