我注意到当我将一个文档添加到 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();
见 this thread在 RavenDB 讨论组了解更多信息
关于metadata - RavenDB 更改元数据 "Raven-Entity-Name",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3635954/