RavenDB Id的特殊配置

时间:2012-12-27 17:27:57

标签: ravendb

我想在Id的RavenDB上调整两个小东西,所以我执行以下代码:

documentStore.Conventions.FindIdentityProperty = (prop) => prop.Name == "ID";
documentStore.Conventions.DocumentKeyGenerator = (entity) => entity.GetType().FullName + "/";

但是这些代码行只有在没有启用其他行的情况下才有效,我无法让两者一起工作。

这有可能吗?

谢谢!

1 个答案:

答案 0 :(得分:3)

我完全按照您提供的方式测试了您的代码,它适用于RavenDB 1.0.992。我认为你使用的是旧版本。

但实际上,您应该自定义FindTypeTagName约定而不是DocumentKeyGenerator

documentStore.Conventions.FindIdentityProperty = prop => prop.Name == "ID";
documentStore.Conventions.FindTypeTagName = type => type.FullName;