コード例 #1
0
        /// <summary>
        /// Will return null, if user will not want to create a new database
        /// </summary>
        /// <returns></returns>
        public ISessionFactory CreateSessionFactory()
        {
            FirebirdEmbeddedPreparer.EnsureFirebirdReady();


            // Ask if user wants to create a database
            // If this class will be used from non-gui environment, this code will have
            // to be extracted somewhere else
            if (EmptyFirebirdDatabasePreparer.ExistsFile() == false)
            {
                var res = MessageBox.Show("FireBird databse not yet created. Do you want to create it now?",
                                          "Db not exists",
                                          MessageBoxButtons.YesNo,
                                          MessageBoxIcon.Question);
                if (res == DialogResult.No)
                {
                    return(null);
                }
                EmptyFirebirdDatabasePreparer.Copy();
                this.Export = true;
            }


            var pathToDB = Path.Combine(Directory.GetCurrentDirectory(), "frmSample60.fdb");

            var conf = new FluentNHibernate.Cfg.Db.FirebirdConfiguration()
                       .ShowSql()
                       .ConnectionString(string.Format(@"
	User=SYSDBA;Password=masterkey;Database={0};
	DataSource=localhost; Port=3050;Dialect=3; Charset=UNICODE_FSS;Role=;Connection lifetime=0;Pooling=true;
	MinPoolSize=1;MaxPoolSize=50;Packet Size=8192;ServerType=1;"    , pathToDB));

            m_factory = Fluently.Configure()
                        .Database(conf)
                        .Mappings(m =>
                                  m.FluentMappings.AddFromAssemblyOf <frmSample60>())
                        .ExposeConfiguration(BuildSchema)
                        .BuildSessionFactory();
            return(m_factory);
        }
コード例 #2
0
		/// <summary>
		/// Will return null, if user will not want to create a new database
		/// </summary>
		/// <returns></returns>
		public ISessionFactory CreateSessionFactory()
		{
			FirebirdEmbeddedPreparer.EnsureFirebirdReady();
			
			
			// Ask if user wants to create a database
			// If this class will be used from non-gui environment, this code will have 
			// to be extracted somewhere else
			if (EmptyFirebirdDatabasePreparer.ExistsFile() == false)
			{
				var res = MessageBox.Show("FireBird databse not yet created. Do you want to create it now?",
				                          "Db not exists",
				                          MessageBoxButtons.YesNo,
				                          MessageBoxIcon.Question);
				if (res == DialogResult.No)
				{
					return null;
				}
				EmptyFirebirdDatabasePreparer.Copy();
				this.Export = true;
			}
			
			
			var pathToDB = Path.Combine(Directory.GetCurrentDirectory(), "frmSample60.fdb");
			
			var conf = new FluentNHibernate.Cfg.Db.FirebirdConfiguration()
				.ShowSql()
				.ConnectionString(string.Format(@"
	User=SYSDBA;Password=masterkey;Database={0};
	DataSource=localhost; Port=3050;Dialect=3; Charset=UNICODE_FSS;Role=;Connection lifetime=0;Pooling=true;
	MinPoolSize=1;MaxPoolSize=50;Packet Size=8192;ServerType=1;", pathToDB));
			
			m_factory = Fluently.Configure()
				.Database(conf)
				.Mappings(m =>
				          m.FluentMappings.AddFromAssemblyOf<frmSample60>())
				.ExposeConfiguration(BuildSchema)
				.BuildSessionFactory();
			return m_factory;
		}