Ejemplo n.º 1
0
        public RavenDbRegistry(string connectionStringName)
        {
            For <IDocumentStore>()
            .Singleton()
            .Use(x =>
            {
                var documentStore = new DocumentStore {
                    ConnectionStringName = connectionStringName
                };
                documentStore.InitializeWithDefaults();

                // Create any Facets.
                RavenFacetTags.CreateFacets(documentStore);

                // Wire up the RavenDb profiler.
                // This is -very- MVC specific, of course. You wouldn't find this in the Tests.
                RavenProfiler.InitializeFor(documentStore);

                return(documentStore);
            }
                 )
            .Named("RavenDB Document Store.");

            For <IDocumentSession>()
            .HttpContextScoped()
            .Use(x =>
            {
                var documentStore = x.GetInstance <IDocumentStore>();
                return(documentStore.OpenSession());
            })
            .Named("RavenDb Session -> per Http Request.");
        }
Ejemplo n.º 2
0
        public void InitaliseDocumentStore()
        {
            // Initialise the Store.
            var documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                Conventions = { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }
            };

            documentStore.Initialize();

            // Force query's to wait for index's to catch up. Unit Testing only :P
            documentStore.RegisterListener(new NoStaleQueriesListener());

            // Index initialisation.
            IndexCreation.CreateIndexes(typeof(RecentPopularTags).Assembly, documentStore);

            // Create any Facets.
            RavenFacetTags.CreateFacets(documentStore);

            // Create our Seed Data.
            CreateSeedData(documentStore);

            DocumentStore = documentStore;
        }
Ejemplo n.º 3
0
        // ReSharper disable InconsistentNaming
        protected void Application_Start()
        // ReSharper restore InconsistentNaming
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);

            ViewEngines.Engines.Clear();
            RegisterRazorViewEngine();

            RegisterRoutes(RouteTable.Routes);

            // Seed an demo data.
            SeedDocumentStore(ObjectFactory.GetInstance <IDocumentStore>());

            // Create any Facets.
            RavenFacetTags.CreateFacets(ObjectFactory.GetInstance <IDocumentStore>());

            // Wire up the RavenDb profiler.
            RavenProfiler.InitializeFor(ObjectFactory.GetInstance <IDocumentStore>());
        }