0

I want to work with the DocumentDatabase object. For this I am writing the follwing code but it is not working. It is giving NullReferenceException "Object reference not set to an instance of an object." Please tell me the right way to do this. code is :

 Raven.Database.Config.InMemoryRavenConfiguration configure1 =
            new Raven.Database.Config.InMemoryRavenConfiguration 
            { 
                DatabaseName = databaseName,
                Port=8080 ,
                DataDirectory="~/Data"
            };
        DocumentDatabase database1 = new DocumentDatabase(configure1);
        //database1.GetDocuments(0,3,null);
Rajdeep Paliwal
  • 175
  • 2
  • 14

1 Answers1

0

Use the EmbeddedDocumentStore, and be sure to initialize it. Than create a session and use the session object in order to query the embedded database.

var documentStore = new EmbeddableDocumentStore
{
     DataDirectory = "Data"
}.Initialize();

var session = documentStore.OpenSession();

Than you can do session.Load(id), session.Query or documentStore .DatabaseCommands.

Fitzchak Yitzchaki
  • 9,095
  • 12
  • 56
  • 96
  • Thanks FitZchak But I am not using EmbeddedDocumentStore , I am using simple DocumentStore and I am Running RavenDB in server mode. I am asking about DocumentDatabase and InMemoryRavenConfiguration Class. Have you used them ? – Rajdeep Paliwal Apr 24 '12 at 07:09
  • There is really no good reason for you to create DocumentStore yourself. What is it that you are trying to do? – Ayende Rahien Apr 24 '12 at 09:14
  • I am trying to work with the object of DocumentDatabase Class.Because i want to retrieve all the documents in single database and this class provides me a function "GetDocuments()". – Rajdeep Paliwal Apr 24 '12 at 09:34
  • Do not use the `DocumentDatabase` class, this is not how you should use RavenDB. Use the session object in order to get the documents from the database. – Fitzchak Yitzchaki Apr 24 '12 at 11:59
  • Thanks a lot for the right way Fitzchak then how can I get all document from single Database .please help me. as i have used this line of code : var list = session.Query ("Raven/DocumentsByEntityName").ToArray(); but I am not getting names of documents.. :) – Rajdeep Paliwal Apr 24 '12 at 12:01