Saving document with one-word tag name

36 views
Skip to first unread message

Alan Ciantar

unread,
Jun 20, 2014, 4:54:35 AM6/20/14
to rav...@googlegroups.com
Given, 'SampleData'.

And I want a naming convention that is simply 'Sample' (Sample/1 for example).

Doing this:
store.Conventions.FindTypeTagName = type => type.Name.Replace("Data", "");

Ends up with document being saved as 'sample/1'.

Either way, 
this:    var result = session.Load<SampleData>("Sample/1");
or this:  var result = session.Load<SampleData>("sample/1");

both work. 

Problem is in the studio, if you type 'Sample/1' -> it does not put an underline under it - i.e it doesn't think it exists.

Alan Ciantar

unread,
Jun 20, 2014, 4:55:14 AM6/20/14
to rav...@googlegroups.com
In case I wasn't clear, I'd like it to be Sample/1 not sample/1

Itamar Syn-Hershko

unread,
Jun 20, 2014, 5:12:39 AM6/20/14
to rav...@googlegroups.com
Document IDs are case insensitive, so this sounds like a studio bug

I'd be careful about doing something like type => type.Name.Replace("Data", ""); - I've just recently saw a system that did exactly this string replace and now is stuck in a terrible backwards compatibility limbo (think about what happens when you have other entities with that string). I'd simply do type.Name.Equals("SampleData", InvariantIgnoreCase)?"Sample":type.Name

--

Itamar Syn-Hershko
http://code972.com | @synhershko
Freelance Developer & Consultant


On Fri, Jun 20, 2014 at 11:55 AM, Alan Ciantar <alan.c...@casasoft.com.mt> wrote:
In case I wasn't clear, I'd like it to be Sample/1 not sample/1

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Ciantar

unread,
Jun 20, 2014, 5:20:20 AM6/20/14
to rav...@googlegroups.com
I have something along the lines of:

if (lastType.Name.EndsWith("Data"))
 {
 typeName = lastType.Name.Substring(0, lastType.Name.Length - "Data".Length
 }

But I'll take a look at yours in a second.

Even if Ids are case insensitive, I'd _prefer_ if they were saved as Sample/1 anyway. For aesthetics if nothing else. Seeing as I've always worked with SampleData.

Alan Ciantar

unread,
Jul 7, 2014, 8:45:28 AM7/7/14
to rav...@googlegroups.com
Bumping this - could I get an official reply perhaps? Is there any way to force 'Section/1' not to be saved as 'section/1' ?

Maxim Buryak

unread,
Jul 7, 2014, 11:11:04 AM7/7/14
to rav...@googlegroups.com
Hi Alan!
first, as  Itamar stated, it seems to be studio's fault and a fix will be ready in the next unstable.
About your recent question, in order to save the section the way you want, you could use a custom convention:
using (var store = new DocumentStore()
            {
                Url = "http://localhost:8080",
                DefaultDatabase = "test1",
                Conventions =
                {
                    TransformTypeTagNameToDocumentKeyPrefix = item => item
                }
            })

you may see some more info about Customizations like that at: http://ravendb.net/docs/2.5/client-api/basic-operations/customizing-behavior


On Mon, Jul 7, 2014 at 3:45 PM, Alan Ciantar <alan.c...@casasoft.com.mt> wrote:
Bumping this - could I get an official reply perhaps? Is there any way to force 'Section/1' not to be saved as 'section/1' ?

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


Best Regards,

Maxim Buryak

Programmer

Mobile: + 972-54-217-7751

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811

Alan Ciantar

unread,
Jul 8, 2014, 4:42:48 AM7/8/14
to rav...@googlegroups.com
Thank you, TransformTypeTagNameToDocumentKeyPrefix worked perfectly :)
Reply all
Reply to author
Forward
0 new messages