예제 #1
0
        public void Can_update_schema()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(Unit).Assembly);

            new SchemaUpdate(cfg).Execute(true, false);
        }
예제 #2
0
        public void Can_generate_schema_shared()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly("EasySystem.Mod.Shared");

            new SchemaExport(cfg).Execute(false, true, false);
        }
        public void GenerateSchemaTest()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(Product).Assembly);

            //new SchemaExport(cfg).Execute(false, true, false, false);
        }
예제 #4
0
        public static void Init()
        {
            Configuration config = new Configuration();

            config.AddAssembly("Columbo.Minesweeper.Application");
            config.Configure();

            _SessionFactory = config.BuildSessionFactory();
        }
예제 #5
0
        /// <summary>
        /// The configured.
        /// </summary>
        /// <param name="persistenceModel">
        /// The persistence Model.
        /// </param>
        /// <param name="cfg">
        /// The config.
        /// </param>
        protected override void Configure(PersistenceModel persistenceModel, Configuration cfg)
        {
            var executing = Assembly.GetExecutingAssembly();

            cfg.AddAssembly(executing);
            persistenceModel.AddMappingsFromSource(new NameSpaceTypeSource(executing, typeof(ContactTypeMap).Namespace));
            this.AddConventions(persistenceModel.Conventions);
            persistenceModel.Configure(cfg);
        }
예제 #6
0
        public static Configuration GetConfiguration()
        {
            Configuration cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(Assembly.GetExecutingAssembly());

            return(cfg);
        }
        public clsVendedorBD()
        {
            Configuration cfg = new Configuration();

            cfg.AddAssembly("web.Logic");

            mySessionFactory = cfg.BuildSessionFactory();
            mySesionn        = mySessionFactory.OpenSession();
        }
예제 #8
0
        public void CanGenerateSchema()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(User).Assembly);

            new SchemaExport(cfg).Execute(false, true, false);
        }
예제 #9
0
        public void Can_Generate_Schema()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(MessageEntity).Assembly);

            new SchemaExport(cfg).Execute(false, true, false);
        }
예제 #10
0
        public void CanInsertCustomer()
        {
            //given
            //0.drop the physical database if already exists AND 1.create the physical database
            var connectionInfo = new DbConnectionInfo {
                DatabaseName = "MyFirstNHibernateTest"
            };
            DbMediaBuilder mediaBuilder
                = DbMediaBuilder.For(DatabaseEngine.MsSql2005, connectionInfo);

            mediaBuilder.CreateDatabaseMedia();
            //2.configure nhibernate
            IDictionary <string, string> sqlServerConfigs
                = NhCommonConfigurations.MsSqlServer(connectionInfo);
            var configuration = new Configuration {
                Properties = sqlServerConfigs
            };

            configuration.AddAssembly(typeof(Customer).Assembly);
            //3.create the database schema
            new SchemaExport(configuration).Execute(true, true, false);

            //4.setup session factory
            ISessionFactory sessionFactory = configuration.BuildSessionFactory();

            //5.Create a new customer
            var customer = new Customer("Brian Allen");

            //when
            //6.open a session
            ISession session = sessionFactory.OpenSession();

            //7.make customer a persistent instance (using the session)
            session.Save(customer);
            //8.open transaction
            using (ITransaction tx = session.BeginTransaction())
            {
                //9.flush the session to the database
                //  ??
                //10.commit transaction
                tx.Commit();
            }

            //11.open a new session
            using (ISession newSession = sessionFactory.OpenSession())
            {
                //12.retrieve persistent customer as stored in the database
                var customerFromDb = newSession.Get <Customer>(customer.Id);

                //13.recursively compare all the 'relevant' properties of:
                //   - the customer constructed in the test
                //   - the customer as retrieved from the database
                EquivalenceComparer  comparer           = EquivalenceComparer.For <Customer>();
                IEnumerable <string> propertiesNotEqual = comparer.PropertiesNotEqual(customer, customerFromDb);
                Assert.That(propertiesNotEqual, Is.Empty);
            }
        }
예제 #11
0
        public static void ExportSchema()
        {
            var configuration = new Configuration();

            configuration.Configure();
            configuration.AddAssembly(typeof(Unit).Assembly);

            new SchemaExport(configuration).Execute(false, true, false);
        }
예제 #12
0
        public void CanCreateMapping()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(Business.Todo).Assembly);

            Assert.AreNotEqual(cfg.ClassMappings.Count, 0);
        }
예제 #13
0
        public void Can_generate_schema()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly("TradeSys.Modules.Financeiro");

            new SchemaExport(cfg).Execute(false, true, false);
        }
예제 #14
0
        private Configuration GetConfiguration()
        {
            var config = new Configuration().Configure();

            this.mappingAssemblies.ForEach(ma => config.AddAssembly(ma));
            config.SetInterceptor(new SqlQueryInterceptor());

            return(config);
        }
        private static void ExportSchema()
        {
            var config = new Configuration();

            config.Configure();
            config.AddAssembly(typeof(GGTestProduct).Assembly);

            new SchemaExport(config).Execute(false, true, false);
        }
예제 #16
0
        public void TestFixtureSetUp()
        {
            _logger.Debug("Starting test series");
            _cfg = new Configuration();
            _cfg.Configure();
            _cfg.AddAssembly(typeof(Person).Assembly);

            _factory = _cfg.BuildSessionFactory();
        }
예제 #17
0
        public void Setup()
        {
            _configuration = new Configuration();
            _configuration.Configure();
            _configuration.AddAssembly(typeof(Business).Assembly);
            _sessionFactory = _configuration.BuildSessionFactory();

            new SchemaExport(_configuration).Execute(false, true, false);
        }
예제 #18
0
        public ClienteDB()
        {
            Configuration cfg = new Configuration();

            cfg.AddAssembly("InvoiceServices.Logic");

            mySessionFactory = cfg.BuildSessionFactory();
            mySession        = mySessionFactory.OpenSession();
        }
예제 #19
0
        public FNHibernate()
        {
            InitializeComponent();

            cfg = new Configuration();
            cfg.AddAssembly("EjemploNHibernate");

            factory = cfg.BuildSessionFactory();
        }
        /// <summary>
        /// Add a new assembly to the configuration and build a new SessionFactory.
        /// </summary>
        /// <param name="assembly"></param>
        public void AddAssembly(Assembly assembly)
        {
            Configuration nhConfiguration = this._kernel[typeof(Configuration)] as Configuration;

            nhConfiguration.AddAssembly(assembly);
            ISessionFactory newSessionFactory = nhConfiguration.BuildSessionFactory();

            ReplaceSessionFactory(newSessionFactory);
        }
예제 #21
0
        public RepositoryBase()
        {
            cfg = new Configuration();
            cfg.Configure();
            cfg.AddAssembly(typeof(T).Assembly);

            factory = cfg.BuildSessionFactory();
            session = factory.OpenSession();
        }
예제 #22
0
        public void Setup()
        {
            _cfg = new Configuration();

            _cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            _cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
            _cfg.SetProperty("connection.connection_string", _connectionString);
            _cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
            _cfg.SetProperty("show_sql", "true");

            _cfg.AddAssembly(typeof(NHibernateSagaRepository <>).Assembly);
            _cfg.AddAssembly(typeof(RegisterUserStateMachine).Assembly);
            _cfg.AddAssembly(typeof(When_using_the_saga_locator_with_NHibernate).Assembly);

            _sessionFactory = _cfg.BuildSessionFactory();

            _sagaId = CombGuid.Generate();
        }
예제 #23
0
파일: NHHelper.cs 프로젝트: h4ltYu/EOS
        public void Configure()
        {
            Configuration configuration = new Configuration().Configure();

            configuration.AddAssembly("QuestionLib");
            configuration.Properties["hibernate.connection.connection_string"] = NHHelper.ConnectionString;
            configuration.Properties["connection.connection_string"]           = NHHelper.ConnectionString;
            this.SessionFactory = configuration.BuildSessionFactory();
        }
        public static Configuration RecuperaConfiguracao()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(Assembly.GetExecutingAssembly());

            return(cfg);
        }
예제 #25
0
        public void Can_generate_schema()
        {
            var cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(Court).Assembly);

            //new SchemaExport(cfg).Execute(false, true, false, false);
        }
예제 #26
0
        static clsNHProducto()
        {
            Configuration cfg = new Configuration();

            cfg.AddAssembly("Parcial.Logica");

            mySessionFactory = cfg.BuildSessionFactory();
            mySession        = mySessionFactory.OpenSession();
        }
        public void Update_an_existing_database_schema()
        {
            _cfg = new Configuration();
            _cfg.Configure();
            _cfg.AddAssembly(Assembly.LoadFrom("DataLayer.dll"));
            var update = new SchemaUpdate(_cfg);

            update.Execute(true, false);
        }
예제 #28
0
        protected Configuration initConfiguration <T>(string conStr)
        {
            var config = new Configuration();

            config.Configure();
            config.AddAssembly(typeof(T).Assembly);
            config.Properties["connection.connection_string"] = conStr;
            return(config);
        }
예제 #29
0
 public void TestFixtureSetUp()
 {
     cfg = new Configuration();
     cfg.AddAssembly("EntityNameInAction.Abstraction.Entities.Mappings");
     cfg.Configure();
     new SchemaExport(cfg).Create(false, true);
     sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
     DI.StackResolver(new NhAdapters.NhEntityClassResolver(sessions));
 }
        public static Configuration RecuperaConfiguracao()
        {
            Configuration cfg = new Configuration();

            cfg.Configure();
            cfg.AddAssembly(typeof(Usuario).Assembly);

            return(cfg);
        }
예제 #31
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder
                .Register<NHibernateImplementationTypeChecker>(
                    c => new NHibernateImplementationTypeChecker(
                        c.Resolve<Func<IEnumerable<IImplementationTypeChecker>>>()))
                .As<INHibernateImplementationTypeChecker>()
                .As<IImplementationTypeChecker>()
                .InstancePerDependency();

            builder
                .Register<NHibernateActionsManager>(
                    c => new NHibernateActionsManager(
                        c.Resolve<ILifetimeScope>(),
                        c.Resolve<IDeploymentRestrictor>()))
                .As<INHibernateActionsManager>()
                .InstancePerLifetimeScope();

            builder
                .Register<ISessionFactory>(
                    c => {
                        var zetboxConfig = c.Resolve<ZetboxConfig>();
                        var result = new Configuration();
                        var connectionString = zetboxConfig.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey);
                        result.Properties["dialect"] = connectionString.DatabaseProvider;
                        result.Properties["connection.connection_string"] = connectionString.ConnectionString;
                        result.Properties["max_fetch_depth"] = "1"; // keep SQL statements small

                        return result
                            .AddAssembly(typeof(NHibernateModule).Assembly)
                            .BuildSessionFactory();
                    })
                .SingleInstance();

            builder
                .Register<ISession>(
                    (c, p) => {
                        var result = c.Resolve<ISessionFactory>().OpenSession(c.Resolve<IInterceptor>());
                        Logging.Log.DebugFormat("Created ISession: {0}", result.GetHashCode());
                        return result;
                    })
                .OnRelease(s => Logging.Log.DebugFormat("Disposed ISession: {0}", s.GetHashCode()))
                // TODO: reconsider this configuration
                //       using IPD makes it safer, but requires passing the session manually
                //       on the other hand, the session should never escape the data context
                .InstancePerDependency();
        }
예제 #32
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder
                .Register<NHibernateImplementationTypeChecker>(
                    c => new NHibernateImplementationTypeChecker(
                        c.Resolve<Func<IEnumerable<IImplementationTypeChecker>>>()))
                .As<INHibernateImplementationTypeChecker>()
                .As<IImplementationTypeChecker>()
                .InstancePerDependency();

            builder
                .Register<NHibernateActionsManager>(
                    c => new NHibernateActionsManager(
                        c.Resolve<ILifetimeScope>(),
                        c.Resolve<IEnumerable<ImplementorAssembly>>()))
                .As<INHibernateActionsManager>()
                .InstancePerLifetimeScope();

            builder
                .Register<ISessionFactory>(
                    c => {
                        var zetboxConfig = c.Resolve<ZetboxConfig>();
                        using (Logging.Log.InfoTraceMethodCall("Init NH Session Factory"))
                        {
                            var result = new Configuration();
                            var connectionString = zetboxConfig.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey);
                            result.Properties["dialect"] = connectionString.DatabaseProvider;
                            result.Properties["connection.connection_string"] = connectionString.ConnectionString;
                            result.Properties["max_fetch_depth"] = "1"; // keep SQL statements small

                            return result
                                .AddAssembly(typeof(NHibernateModule).Assembly)
                                .BuildSessionFactory();
                        }
                    })
                .SingleInstance();
        }
예제 #33
0
        protected virtual Configuration CreateNHibernateConfiguration( Assembly[] inputAssemblies, ProxyGeneratorOptions options )
        {
            Configuration nhibernateConfiguration = new Configuration();

            //nhibernateConfiguration.AddProperties(GetDefaultNHibernateProperties(options));
            nhibernateConfiguration.SetProperties(GetDefaultNHibernateProperties(options));

            foreach (Assembly inputAssembly in inputAssemblies)
            {
                nhibernateConfiguration.AddAssembly(inputAssembly);
            }

            return nhibernateConfiguration;
        }