当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.Configure方法代码示例

本文整理汇总了C#中NHibernate.Cfg.Configuration.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Configure方法的具体用法?C# Configuration.Configure怎么用?C# Configuration.Configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.Configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppDomainFactory

 public static ISessionFactory AppDomainFactory()
 {
     if (_appDomainFactory == null)
     {
         lock (_synRoot3)
         {
             if (_appDomainFactory == null)
             {
                 var createSchema = false;
                 var configuration = new Configuration()
                     .DataBaseIntegration(d =>
                     {
                         d.ConnectionStringName = Constants.APP_DB;
                         d.Dialect<MsSql2012Dialect>();
                         //d.Dialect<Oracle10gDialect>();
                         d.SchemaAction = SchemaAutoAction.Validate;
                     })
                     .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                     .CurrentSessionContext<LazySessionContext>()
                     .SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none")
                     .SetProperty(NHibernate.Cfg.Environment.Hbm2ddlAuto, (createSchema == true) ? SchemaAutoAction.Update.ToString() : SchemaAutoAction.Validate.ToString());
                 configuration.AddMapping(GetAppMappings());
                 configuration.BuildMapping();
                 if (File.Exists(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY])))
                     configuration.Configure(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY]));
                 if (File.Exists(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY_App])))
                     configuration.Configure(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY_App]));
                 //new NHibernate.Tool.hbm2ddl.SchemaExport(configuration).SetOutputFile(@"c:\temp\MyDDL.sql").Execute(true /*script*/, true /*export to db*/, false /*just drop*/);
                 _appDomainFactory = configuration.BuildSessionFactory();
             }
         }
     }
     return _appDomainFactory;
 }
开发者ID:jmptrader,项目名称:WebFrameworkMVC,代码行数:34,代码来源:NHibernateConfig.cs

示例2: Load

        public override void Load()
        {
            Bind<IUnitOfWorkFactory>().ToFactory();
            Bind<IRepositoryFactory>().ToFactory();
            Bind<IUnitOfWork>().To<UnitOfWork>();
            Bind<ISessionFactory>().ToMethod(ctx =>
            {
                var cfg = new Configuration();
#if DEBUG
                cfg.Configure();
#else
                cfg.Configure(Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, "hibernate-release.cfg.xml"));
#endif
                cfg.AddAssembly(Assembly.GetExecutingAssembly());
                return cfg.BuildSessionFactory();
            });
            Bind<IRepository<User>, IUserRepository>().To<UserRepository>();
            Bind<IRepository<Artist>>().To<ArtistRepository>();
            Bind<IRepository<Album>>().To<AlbumRepository>();
            Bind<IRepository<Track>>().To<TrackRepository>();
            Bind<IRepository<Playlist>, IPlaylistRepository>().To<PlaylistRepository>();
            Bind<IRepository<SocialNetwork>, ISocialNetworkRepository>().To<SocialNetworkRepository>();
            Bind<IRepository<UserSocialNetwork>, IUserSocialNetworkRepository>().To<UserSocialNetworkRepository>();
            Bind<IRepository<PlaylistTrack>>().To<PlaylistTrackRepository>();
            Bind<IRepository<PlaylistListener>>().To<PlaylistListenersRepository>();
            Bind<IRepository<SharedPlaylist>>().To<SharedPlaylistRepository>();
            Bind<IRepository<PlaylistLike>>().To<PlaylistLikerRepository>();
            Bind<IRepository<Notification>, INotificationRepository>().To<NotificationRepository>();
        }
开发者ID:B1naryStudio,项目名称:Azimuth,代码行数:29,代码来源:DataAccessModule.cs

示例3: BuildSessionFactory

        private void BuildSessionFactory()
        {
            try
            {
                var config = new Configuration();

                if (string.IsNullOrEmpty(_configurationFile))
                {
                    config.Configure();
                }
                else
                {
                    config.Configure(_configurationFile);
                }

                config.AddAssembly(typeof (NhUnitOfWork).Assembly);

                _sessionFactory = config.BuildSessionFactory();
            }
            catch (Exception)
            {
                _sessionFactory = null;
                throw;
            }
        }
开发者ID:Drake103,项目名称:ewg,代码行数:25,代码来源:NhUnitOfWorkFactory.cs

示例4: Configure

        /// <summary>
        /// Configure according to hibernate.cfg.xml
        /// </summary>
        /// <param name="config">Configuration to apply the config file to</param>
        /// <param name="hibernateFile">Hibernate file path</param>
        /// <returns>Updated configuration</returns>
        private static Configuration Configure(Configuration config,
                string hibernateFile)
        {
            // In case that hibernate config file location is null find hibernate.cfg.xml
            // file in classpath
            if (hibernateFile == null)
                return config.Configure();

            return config.Configure(hibernateFile);
        }
开发者ID:GigaSpaces-ProfessionalServices,项目名称:xapnet-templates,代码行数:16,代码来源:SessionFactoryBuilder.cs

示例5: CreateConfiguration

 /// <summary>
 /// Creates a NHibernate configuration object containing mappings for this model.
 /// </summary>
 /// <returns>A NHibernate configuration object containing mappings for this model.</returns>
 public static Configuration CreateConfiguration()
 {
     var configuration = new Configuration();
       configuration.Configure();
       ApplyConfiguration(configuration);
       return configuration;
 }
开发者ID:Maharba,项目名称:LittleBooks,代码行数:11,代码来源:Libros.cs

示例6: createConfiguration

 private Configuration createConfiguration()
 {
     Configuration cfg = new Configuration();
     cfg.Configure();
     cfg.AddAssembly(typeof(Mesto).Assembly);
     return cfg;
 }
开发者ID:stankela,项目名称:clanovi,代码行数:7,代码来源:PersistentConfigurationBuilder.cs

示例7: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     _configuration = new Configuration();
     _configuration.Configure();
     _configuration.AddAssembly(typeof(Product).Assembly);
     _sessionFactory = _configuration.BuildSessionFactory();
 }
开发者ID:tasluk,项目名称:hibernatingrhinos,代码行数:7,代码来源:ProductRepository_Fixture.cs

示例8: CargarListas

        /// <summary>
        /// Carga las listas de la BD que se necesitan para las consultas
        /// </summary>
        private void CargarListas()
        {
            //Iniciar sesión
            var cfg = new Configuration();
            cfg.Configure();
            var sessions = cfg.BuildSessionFactory();
            var sess = sessions.OpenSession();

            //Consulta a la BD
            IQuery q1 = sess.CreateQuery("FROM Cliente");
            var clientesTodos = q1.List<Cliente>();

            //Actualización de la lista global de clientes
            clientes = clientesTodos.ToList<Cliente>();

            //Consulta a la BD
            IQuery q2 = sess.CreateQuery("FROM Empleada");
            var empleadosTodos = q2.List<Empleada>();

            //Actualización de la lista global de clientes
            empleados = empleadosTodos.ToList<Empleada>();

            //Carga en las tablas
            sess.Close();
        }
开发者ID:powerponch,项目名称:LaModisteria,代码行数:28,代码来源:NotasDelClienteForm.xaml.cs

示例9: GetConfiguration

 private static Configuration GetConfiguration()
 {
     var config = new Configuration();
     config.Configure();
     config.ConfigureMembershipReboot();
     return config;
 }
开发者ID:KeithBarrows,项目名称:BrockAllen.MembershipReboot,代码行数:7,代码来源:NhibernateConfig.cs

示例10: Init

		private static void Init()
		{
			var config = new Configuration();
			config.Configure();
			config.AddAssembly(Assembly.GetCallingAssembly());
			_sessionFactory = config.BuildSessionFactory();
		}
开发者ID:AdamPrendergast,项目名称:Squarker_ASP.NET_MVC,代码行数:7,代码来源:DatabaseManager.cs

示例11: CriaSessionFactory

 private static ISessionFactory CriaSessionFactory()
 {
     Configuration cfg = new Configuration();
     cfg.Configure();
     return Fluently.Configure(cfg)
     .Mappings(x => x.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())).BuildSessionFactory();
 }
开发者ID:daniloscipioni,项目名称:DaniloRep,代码行数:7,代码来源:NHibernateHelper.cs

示例12: GetConfiguration

 private static Configuration GetConfiguration()
 {
     var config = new Configuration();
     config.Configure();
     config.AddMapping(GetMappings());
     return config;
 }
开发者ID:nothingmn,项目名称:BrockAllen.MembershipReboot,代码行数:7,代码来源:NhibernateConfig.cs

示例13: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Started publisher and inserting data.");
            Publisher.Start();
    
            var config = new Configuration();
            config.Configure("nh.sqlserver.config");
            config.SessionFactoryName("Test session factory");
            config.AddAssembly(typeof(Dog).Assembly);

            new SchemaUpdate(config).Execute(false, true);
            
            using(var sessionFactory = config.BuildSessionFactory())
            {
                Stopwatch sw = new Stopwatch();

                sw.Start();
                InsertData(sessionFactory);
                Console.WriteLine("Inserting data  with logging took: {0}", sw.Elapsed);

                sw.Restart();
                Publisher.Shutdown();
                Console.WriteLine("Publisher shutdown complete in {0}", sw.Elapsed);

                Console.WriteLine("inserting data with publisher shutdown");
                sw.Restart();
                InsertData(sessionFactory);
                Console.WriteLine("Inserting data  without logging took: {0}", sw.Elapsed);
            }
            Console.ReadLine();
        }
开发者ID:seif,项目名称:NHibernate.ZMQLogPublisher,代码行数:31,代码来源:Program.cs

示例14: button3_Click

 private void button3_Click(object sender, EventArgs e)
 {
     var cfg = new Configuration();
     cfg.Configure();
     cfg.AddAssembly(typeof(Domain.User).Assembly);
     var sessions = cfg.BuildSessionFactory();
     var sess = sessions.OpenSession();
     var login = textBox1.Text;
     IQuery q = sess.CreateQuery("FROM User u where u.Login=:login").SetParameter("login",login);
     var list = q.List<Domain.User>();
     if (list.Count > 0 && list[0].Pass == textBox2.Text)
     {
         var role_id = list[0].Role_id;
         IQuery q_role = sess.CreateQuery("FROM Role u where u.Id=:role_id").SetParameter("role_id", role_id);
         var list_role = q_role.List<Domain.Role>();
         if (list_role[0].Name.Equals("reader"))
         {
             LibraryForm lib_form = new LibraryForm(list[0]);
             lib_form.ShowDialog();
         }
         else
         {
             AdminForm admin_form = new AdminForm();
             admin_form.ShowDialog();
         }
     }
     else
     {
         MessageBox.Show("Неверный логин или пароль");
     }
 }
开发者ID:alenkacs,项目名称:library_system,代码行数:31,代码来源:Form1.cs

示例15: NHibernateConfiguration

        public static void NHibernateConfiguration(TestContext context)
        {
            log4net.Config.XmlConfigurator.Configure();

            Configuration = new Configuration();
            // lendo o arquivo hibernate.cfg.xml
            Configuration.Configure();

            FilterDefinition filterDef = new FilterDefinition(
                "Empresa","EMPRESA = :EMPRESA",
                new Dictionary<string, IType>() {{"EMPRESA", NHibernateUtil.Int32}}, false);
            Configuration.AddFilterDefinition(filterDef);
            filterDef = new FilterDefinition(
                "Ativa", "ATIVO = 'Y'",
                new Dictionary<string, IType>(), false);
            Configuration.AddFilterDefinition(filterDef);

            // Mapeamento por código
            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            Configuration.AddMapping(mapping);

            // Gerar o XML a partir do mapeamento de codigo.
            //var mappingXMl = mapping.AsString();

            // Mapeamento por arquivo, in resource.
            Configuration.AddAssembly(Assembly.GetExecutingAssembly());

            // Gerando o SessionFactory
            SessionFactory = Configuration.BuildSessionFactory();
        }
开发者ID:hrickmachado,项目名称:Crowdlearning-Tecnologia-NHibernate,代码行数:32,代码来源:Context.cs


注:本文中的NHibernate.Cfg.Configuration.Configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。