如何在共享托管环境中运行RavenDB?

Ben*_*thy 26 c# shared-hosting ravendb asp.net-mvc-2

RavenDB能够以"嵌入式"模式运行,据我所知,它应该允许它在共享托管环境中运行.

有没有人知道它如何在ASP.NET MVC应用程序中工作,以及这样做的最佳实践是什么?

托管环境中是否存在我需要注意的依赖关系?

Dav*_*ith 13

是.

我使用ASP.NET MVC 3和RavenDB 1.0.0.371 在共享托管环境http://www.winhost.com/中运行RavenDB,该版本于2011年7月左右发布.

我的代码:

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

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

    public static xxx Read(string key)
    {
        using (var session = store.OpenSession())
        {

            var anEntity = session.Query<xxx>().
                Where(item => item.key == key).Single();
            return anEntity;
        }
    }

    public static void Write(xxx)
    {
        using (var session = store.OpenSession())
        {
            session.Store(xxx);
            session.SaveChanges();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

到目前为止唯一的缺点是我没有得到RavenDB管理工作室.

  • 您可以尝试在管理工作室的`returnStore`上使用`UseEmbeddedHttpServer = true` - > http://ravendb.net/faq/embedded-with-http (2认同)