What do I need to do to store objects in RavenDB?

Viewed 3287

I'm using ravendb to serialize an object and test it through mstest.

I am getting this result: System.ArgumentException: Object serialized to String. RavenJObject instance expected.

Here is my code

public class Store
{
    private static IDocumentStore store = createStore();

    private static EmbeddableDocumentStore createStore()
    {
        var returnStore = new EmbeddableDocumentStore();
        returnStore.DataDirectory = @"./PersistedData";
        returnStore.Initialize();
        return returnStore;
    }

    public static void Write(string value)
    {
        using (var session = store.OpenSession())
        {
            session.Store(value);
            session.SaveChanges();
        }
    }
}

It seems the root cause is in how RavenJObject works as this throws the same error:

RavenJObject storeMe = RavenJObject.FromObject("errors", new JsonSerializer());

How do I do custom serialization in RavenDB?

3 Answers
Related