private IDocumentSession CreateSession()
 {
     if (!string.IsNullOrWhiteSpace(_configSettings.GetDatabaseName()))
     {
         return(_documentStore.OpenSession(_configSettings.GetDatabaseName()));
     }
     else
     {
         return(_documentStore.OpenSession());
     }
 }
 protected override IDocumentSession CreateInstance(IContext ctx)
 {
     if (!string.IsNullOrWhiteSpace(_configSettings.GetDatabaseName()))
     {
         return(_documentStore.OpenSession(_configSettings.GetDatabaseName()));
     }
     else
     {
         return(_documentStore.OpenSession());
     }
 }
Exemple #3
0
        protected override IDocumentStore CreateInstance(IContext ctx)
        {
            var documentStore = new DocumentStore
            {
                Url = _configSettings.GetDatabaseUrl()
            };

            var hasDefaultDatabase = !string.IsNullOrWhiteSpace(_configSettings.GetDatabaseName());

            if (hasDefaultDatabase)
            {
                documentStore.DefaultDatabase = _configSettings.GetDatabaseName();
            }

            //documentStore.Conventions.FindIdentityProperty =
            //                    prop =>
            //                        // My custom ID for a given class.
            //                        //(prop.DeclaringType.IsSubclassOf(typeof(DomainModelWithId)) && prop.Name == "Id")
            //                        //(prop.DeclaringType == typeof(Role) && prop.Name == "Id")
            //                        //|| (prop.DeclaringType == typeof(Permission) && prop.Name == "Id")
            //                        // Default to general purpose.
            //                        //prop.Name == "Id";
            //                        prop.Name == "Id";

            // Set type name handling to avoid Raven serialising type info into Activity documents. We load Activities straight out of the
            // db and send the to the UI. They need to be clean from the outset.
            //documentStore.Conventions.CustomizeJsonSerializer = serializer =>
            //{
            //    serializer.TypeNameHandling = TypeNameHandling.None;
            //};

            documentStore.RegisterListener(_ravenDocumentStoreListener);

            documentStore.Initialize();

            if (hasDefaultDatabase)
            {
                documentStore.DatabaseCommands.EnsureDatabaseExists(_configSettings.GetDatabaseName());
            }

            IndexCreation.CreateIndexes(typeof(All_Groups).Assembly, documentStore);
            All_Activities.Create(documentStore);

            return(documentStore);
        }