Overriding Id generation

186 views
Skip to first unread message

Ben

unread,
May 6, 2012, 7:44:01 AM5/6/12
to ravendb
I'm storing generic types and so far have created a custom
FindTypeTagName convention so that the my ReferenceList<T> are stored
as /referencelists/{id} instead of ReferenceListsOfSomething/{id}.

Now I would like to use the generic type name as the Id. I created the
following convention:

documentStore.Conventions.DocumentKeyGenerator =
e => IsReferenceList(e.GetType())
?
documentStore.Conventions.GetTypeTagName(e.GetType()) + "/" +
GetReferenceListItemType(e)
:
documentStore.Conventions.GetTypeTagName(e.GetType()) + "/";

So given a ReferenceList<SalaryRange> we currently get an Id of /
referencelists/salaryrange.

Question: How can I use the pluraliser that Raven uses when generating
the ids, so that I get /salaryrangeS instead of /salaryrange.

Also, can someone confirm that
[documentStore.Conventions.GetTypeTagName(e.GetType()) + "/"] is the
default key generator as I don't want to change the strategy for any
other types.

Thanks,
Ben

Itamar Syn-Hershko

unread,
May 6, 2012, 8:03:03 AM5/6/12
to rav...@googlegroups.com
The pluralizer is a simple function call you can make to Raven.Client.Util.Inflector.Pluralize(word)

The DocumentKeyGenerator is pointing to the default method being used to return a string ID for a given object. By default Raven.Client.Document.MultiTypeHiLoKeyGenerator is used (specifically, GenerateDocumentKey).
Reply all
Reply to author
Forward
0 new messages