public static ISession OpenTemporarySession()
        {
            lock (factorylock)
            {
                if (_sessionSource == null)
                {
                    var persistenceModel = new PersistenceModel();
                    persistenceModel.AddMappingsFromAssembly(typeof(JiraIssueMap).Assembly);

                    var sqLiteConfiguration = new SQLiteConfiguration()
                                              .InMemory()
                                              .ShowSql();

                    var sessionSource = new SessionSource(sqLiteConfiguration.ToProperties(), persistenceModel);

                    _sessionSource = sessionSource;
                }
            }

            var session = _sessionSource.CreateSession();

            _sessionSource.BuildSchema(session);

            return(session);
        }
        protected void ShowSchema()
        {
            var cfg = new SQLiteConfiguration()
                      .InMemory()
                      .ShowSql();
            var configuration = new Configuration().AddProperties(cfg.ToProperties());
            var model         = new TModel();

            model.Configure(configuration);
            new SchemaExport(configuration).Create(true, false);
        }
        public void SetupContext()
        {
            var cfg = new SQLiteConfiguration()
                      .InMemory()
                      .ShowSql();

            SessionSource = new SessionSource(cfg.ToProperties(), new TModel());
            Session       = SessionSource.CreateSession();
            SessionSource.BuildSchema(Session);

            Context();
            Session.Flush();
            Session.Clear();

            Because();
        }
예제 #4
0
        /// <summary>
        /// Returns the FluentNHibernate Sqlite configuration data
        /// </summary>
        /// <param name="assembly">The assembly containing the mappings</param>
        /// <returns>SQLite configuration</returns>
        IPersistenceConfigurer IDatabaseConfiguration.Create(Assembly assembly)
        {
            SQLiteConfiguration config = new SQLiteConfiguration()
                                            .UsingFile(m_strDbPath)
                                            .ProxyFactoryFactory("NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu")
                                            .ShowSql();

            if (!File.Exists(m_strDbPath))
            {
                PersistenceModel pm = new PersistenceModel();
                pm.AddMappingsFromAssembly(assembly);

                SessionSource ss = new SessionSource(config.ToProperties(), pm);
                ss.BuildSchema();
                ss = null;
            }

            return config;
        }