How can I run RavenDB in a shared hosting environment?

前端 未结 1 1768
孤街浪徒
孤街浪徒 2020-12-13 09:40

RavenDB has the ability to run in \'embedded\' mode, which as far as I understand, should allow it to be run in a shared hosting environment.

Does anyone have any id

相关标签:
1条回答
  • 2020-12-13 10:29

    Yes.

    I have RavenDB running in a shared hosting environment, http://www.winhost.com/, using ASP.NET MVC 3 and RavenDB 1.0.0.371 which was released somewhere around July 2011.

    My code:

    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();
            }
        }
    }
    

    The only downside so far is I don't get the RavenDB management studio.

    0 讨论(0)
提交回复
热议问题