Inheritance: ISessionSource
Beispiel #1
0
 public void AutoCriarBancoDeDados(ISession session)
 {
     InitSessionFactory();
     var sessionSource = new SessionSource(_fluentConfiguration);
     sessionSource.BuildSchema(session);
     session.Flush();
 }
        /// <summary>
        /// Configures the storage with the user supplied persistence configuration
        /// Azure tables are created if requested by the user
        /// </summary>
        /// <param name="config"></param>
        /// <param name="connectionString"></param>
        /// <param name="createSchema"></param>
        /// <returns></returns>
        public static Configure AzureSubcriptionStorage(this Configure config,
            string connectionString,
            bool createSchema)
        {
            var database = MsSqlConfiguration.MsSql2005
                .ConnectionString(connectionString)
                .Provider(typeof(TableStorageConnectionProvider).AssemblyQualifiedName)
                .Dialect(typeof(TableStorageDialect).AssemblyQualifiedName)
                .Driver(typeof(TableStorageDriver).AssemblyQualifiedName)
                .ProxyFactoryFactory(typeof(ProxyFactoryFactory).AssemblyQualifiedName);

            var fluentConfiguration = Fluently.Configure()
                .Database(database)
                .Mappings(m => m.FluentMappings.Add(typeof (SubscriptionMap)));
            var configuration = fluentConfiguration.BuildConfiguration();

            var sessionSource = new SessionSource(fluentConfiguration);

            if (createSchema)
            {
                using (var session = sessionSource.CreateSession())
                {
                    new SchemaExport(configuration).Execute(true, true, false, session.Connection, null);
                    session.Flush();
                }
            }

            config.Configurer.RegisterSingleton<ISessionSource>(sessionSource);
            config.Configurer.ConfigureComponent<SubscriptionStorage>(DependencyLifecycle.InstancePerCall);

            return config;
        }
Beispiel #3
0
        public Form1( )
        {
            InitializeComponent();

              if (!File.Exists("SiqualRunner.db"))
              {
            ISessionSource s = new SessionSource(new SQLRPersistenceModel());
            s.BuildSchema();
              }

              toolTip1.SetToolTip(chkRunAtomic, "All files are ran in one transaction.");

              PrepareGridView();
              InitPanels();

              Closing += Form1Closing;
              gvFileList.MouseUp += GvFileListMouseUp;
              notifyIcon.Click += NotifyIconClick;
              Resize += Form1Resize;

              lstProjects.DrawMode = DrawMode.OwnerDrawVariable;
              lstProjects.DrawItem += ListBox1DrawItem;
              lstProjects.MeasureItem += ListBox1MeasureItem;

              _timer.Interval = 1000 * 60 * 3; // 3 minutes
              _timer.Enabled = true;
              _timer.Tick += TimerTick;
              _timer.Start();
        }
 public void RecreateDb(ISession session)
 {
     InitSessionFactory();
     var sessionSource = new SessionSource(_fluentConfiguration);
     sessionSource.BuildSchema(session);
     session.Flush();
 }
 protected virtual void Before_each_test()
 {
     SessionSource = new SessionSource(new TestModel());
     Session = SessionSource.CreateSession();
     SessionSource.BuildSchema(Session);
     CreateInitialData(Session);
     Session.Clear();
 }
Beispiel #6
0
        public void SetupContext()
        {
            var cfg = Fluently.Configure().Database(SQLiteConfiguration.Standard.InMemory);

            SessionSource = new SessionSource(cfg.BuildConfiguration().Properties, new TestModel());
            Session = SessionSource.CreateSession();
            SessionSource.BuildSchema(Session);
        }
 protected virtual void Context()
 {
     SessionSource = new SessionSource(new TestModel());
     Session = SessionSource.CreateSession();
     SessionSource.BuildSchema(Session);
     CreateInitialData(Session);
     Session.Flush();
     Session.Clear();
 }
        public ISessionSource CreateSessionSource(PersistenceModel model)
        {
            var properties = GetProperties();
            var source = new SessionSource(properties, model);

            create_schema_if_it_does_not_already_exist(source);

            return source;
        }
 public void AutoCriarBancoDeDados()
 {
     if (_fluentConfiguration != null)
     {
         var sessionSource = new SessionSource(_fluentConfiguration);
         ISession session = sessionSource.CreateSession();
         sessionSource.BuildSchema(session);
     }
 }
        public void Setup()
        {
            var model = NHibernateHelper.SkapaPeristanceModel();

            var cfg = Fluently.Configure()
                .Database(SQLiteConfiguration.Standard.ShowSql().InMemory);

            _sessionSource = new SessionSource(cfg.BuildConfiguration().Properties, model);

            _sessionHelper = new SQLiteSessionHelper(_sessionSource);
            _sessionHelper.StartSession();
            _sessionSource.BuildSchema(_sessionHelper.GetCurrentSession());
        }
        public ISessionSource GetSessionSource()
        {
            var config = _mappings.Generate()
                .Database(SQLiteConfiguration.Standard.InMemory()
                              .ProxyFactoryFactory(typeof(NHibernate.ByteCode.LinFu.ProxyFactoryFactory)))
                .ExposeConfiguration(EventListenerRegistrations.Apply);

            var sessionSource = new SessionSource(config);

            if (ShouldGenerateDb)
                sessionSource.BuildSchema();

            return sessionSource;
        }
Beispiel #12
0
        public EasyWorshipReader(string easyWorshipSongPath)
        {
            var initialConfiguration = new Configuration();
            initialConfiguration.SetNamingStrategy(new ParadoxNamingStrategy());

            var fluentConfiguration =
                Fluently.Configure(initialConfiguration)
                    .Database(JetDriverConfiguration.Standard.ConnectionString(
                        $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={easyWorshipSongPath};Extended Properties=\"Paradox 5.x;CharacterSet=65001;\"")
                        .Dialect<JetDialect>()
                        .Driver<OleDbDriver>())
                    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MainForm>());

            _sessionSource = new SessionSource(fluentConfiguration);
        }
        public ISessionSource GetSessionSource()
        {
            var config = _mappings.Generate()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(_connectionString)
                              .ProxyFactoryFactory(typeof (NHibernate.ByteCode.LinFu.ProxyFactoryFactory)))
                              .ExposeConfiguration(EventListenerRegistrations.Apply);
             
        
            var sessionSource = new SessionSource(config);


            if (ShouldGenerateDb)
                sessionSource.BuildSchema();

            return sessionSource;
        }
        public void SetUp()
        {
            FluentConfiguration config = Fluently
                .Configure()
                .Database(SQLiteConfiguration.Standard.InMemory().ShowSql())
                .Mappings(
                    m =>
                        {
                            m.FluentMappings.AddFromAssemblyOf<Vehicle>();
                            m.AutoMappings.Add(
                                AutoMap
                                    .AssemblyOf<Plant>()
                                    .Where(x => x.Namespace == "Fluent.Entities"));
                        });

            _sessionSource = new SessionSource(config);
            _session = _sessionSource.CreateSession();
            _sessionSource.BuildSchema(_session);
        }
Beispiel #15
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;
        }
        public PersistenceRegistry()
        {
            var mssqlConfig = MsSqlConfiguration
                .MsSql2005
                .ConnectionString(c => c.FromConnectionStringWithKey("FubuTaskDB"))
                .UseOuterJoin();

            var source = new SessionSource(
                Fluently.Configure()
                    .Database(mssqlConfig)
                    .Mappings(c => c.AutoMappings.Add(new GuidEntityPersistenceModel<Entity>()))
                );

            ForRequestedType<ISessionSource>().AsSingletons()
                .TheDefault.IsThis(source);

            ForRequestedType<IUnitOfWork>()
                .TheDefault.Is.ConstructedBy(ctx => ctx.GetInstance<INHibernateUnitOfWork>());

            ForRequestedType<INHibernateUnitOfWork>().CacheBy(InstanceScope.Hybrid)
                .TheDefault.Is.OfConcreteType<NHibernateUnitOfWork>();

            ForRequestedType<IRepository<Guid>>().TheDefault.Is.OfConcreteType<NHibernateRepository<Guid>>();
        }
 public ISessionSource CreateSessionSource()
 {
     var source = new SessionSource(BuildFluentConfig());
     return source;
 }
        /// <summary>
        /// Configures the storage with the user supplied persistence configuration
        /// DB schema is updated if requested by the user
        /// </summary>
        /// <param name="config"></param>
        /// <param name="nhibernateProperties"></param>
        /// <param name="autoUpdateSchema"></param>
        /// <returns></returns>
        public static Configure DBSubcriptionStorage(this Configure config,
            IDictionary<string, string> nhibernateProperties,
            bool autoUpdateSchema)
        {

            var fluentConfiguration = Fluently.Configure(new Configuration().SetProperties(nhibernateProperties))
              .Mappings(m => m.FluentMappings.Add(typeof(SubscriptionMap)));

            var cfg = fluentConfiguration.BuildConfiguration();

            if (autoUpdateSchema)
                new SchemaUpdate(cfg).Execute(false, true);

            //default to LinFu if not specifed by user
            if (!cfg.Properties.Keys.Contains(PROXY_FACTORY_KEY))
                fluentConfiguration.ExposeConfiguration(
                    x =>
                    x.SetProperty(PROXY_FACTORY_KEY, typeof(ProxyFactoryFactory).AssemblyQualifiedName));

            var sessionSource = new SessionSource(fluentConfiguration);


            config.Configurer.RegisterSingleton<ISessionSource>(sessionSource);
            config.Configurer.ConfigureComponent<SubscriptionStorage>(ComponentCallModelEnum.Singlecall);

            return config;

        }
 public void Create()
 {
     ISessionSource s = new SessionSource(new SQLRPersistenceModel());
     s.BuildSchema();
 }
Beispiel #20
0
 private static void BuildSchema(FluentConfiguration configuration)
 {
     var sessionSource = new SessionSource(configuration);
     var session = sessionSource.CreateSession();
     sessionSource.BuildSchema(session);
 }