문제

I'd like to write my own simple desktop based RavenDB explorer, similar to the Web UI. This is for learning Raven, mostly.

So my first task is to read all documents from the db, doesn't matter what app they belong to. I'd like to achieve this using the client API, but it seems like both session.Query and session.LuceneQuery require class specifier.

What API should I use for this task?

도움이 되었습니까?

해결책

The Client API requires a type because it's designed to work with CLR POCO and so handles the conversion (from Json) for you.

You will need to work directly with the Json in your case as you don't know the type. This is what the Web UI does. I'd recommend looking through the Java-Script code to see how it's done.

Also there is always a default index called "Raven/DocumentsByEntityName" that you can query. This indexes the "Raven-Entity-Name" (corresponding to the CLR type), that is stored in a documents metadata. This is what Raven uses to allow it to convert the Json to a CLR type. See the docs for more info

다른 팁

The below will extract all RavenDB documents in Json:

var docStore = new DocumentStore { Url = "http://localhost:8080" };
using (docStore.Initialize())
{
    var docs = docStore
        .DatabaseCommands
        .Query("Raven/DocumentsByEntityName", new IndexQuery());
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top