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


C# Configuration.SetProperty方法代码示例

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


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

示例1: AlterConfiguration

        protected override void AlterConfiguration(Configuration config) {
            config.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString);

            if (IsAzureSql()) {
                config.SetProperty(NHibernate.Cfg.Environment.TransactionStrategy, typeof(ReliableAdoNetWithDistributedTransactionFactory).AssemblyQualifiedName);
            }
        }
开发者ID:jdages,项目名称:AndrewsHouse,代码行数:7,代码来源:SqlServerDataServicesProvider.cs

示例2: SqlEntityBulkCopy

        /// <summary>
        /// Wrapper class to produce an Ado.Net Datatable from any entity, 
        /// and perform SqlBulkCopy operations
        /// </summary>
        public SqlEntityBulkCopy(string sqlCnnString, Type entityType)
        {
            if (Cfg == null)
            {
                //Note: The NHibernate.Cfg.Configuration is meant only as an initialization-time object.
                //Note: NHibernate.ISessionFactory is immutable and does not retain any association back to the Session

                Cfg = new Configuration();
                //Cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
                Cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2008Dialect");
                Cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
                Cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
                Cfg.SetProperty("connection.connection_string", sqlCnnString);

                //add all the mappings embedded in this assembly
                Cfg.AddAssembly(typeof(SqlEntityBulkCopy).Assembly);

                var sessionFactory = Cfg.BuildSessionFactory();
                SessionFactoryImpl = (ISessionFactoryImplementor)sessionFactory;
            }
            EntityType = entityType;
            //_session = SessionFactoryImpl.OpenSession();
            _metaData = SessionFactoryImpl.GetClassMetadata(EntityType);
            _persistentClass = Cfg.GetClassMapping(EntityType);
            _sqlCnn = new SqlConnection(sqlCnnString);
            _sqlBulkCopy = new SqlBulkCopy(_sqlCnn);

            //Debug.WriteLine("EntityName = " + _metaData.EntityName);
            //Debug.WriteLine("IdentifierPropertyName = " + _metaData.IdentifierPropertyName);
            //Debug.WriteLine("IdentifierType = " + _metaData.IdentifierType);

            BuildDataTable();
            BuildAndMapSqlBulkCopy();
        }
开发者ID:dzstoever,项目名称:ZenFacades,代码行数:38,代码来源:SqlEntityBulkCopy.cs

示例3: Main

    static void Main()
    {
        Console.Title = "Samples.CustomNhMappings.XmlMapping";
        var nhConfiguration = new Configuration();

        nhConfiguration.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
        nhConfiguration.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.Sql2008ClientDriver");
        nhConfiguration.SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2008Dialect");
        nhConfiguration.SetProperty(Environment.ConnectionStringName, "NServiceBus/Persistence");

        AddMappingsFromFilesystem(nhConfiguration);

        var busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.CustomNhMappings.XmlMapping");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();

        var persistence = busConfiguration.UsePersistence<NHibernatePersistence>();
        persistence.UseConfiguration(nhConfiguration);

        using (var bus = Bus.Create(busConfiguration).Start())
        {
            var startOrder = new StartOrder
            {
                OrderId = "123"
            };
            bus.SendLocal(startOrder);
            
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:32,代码来源:Program.cs

示例4: ParseConnectionString

        /// <summary>
        /// Parses the connection string and creates the NHibernate configuration
        /// </summary>
        /// <param name="connect">NHibernate dialect, driver and connection string separated by ';'</param>
        private void ParseConnectionString(string connect)
        {
            // Split out the dialect, driver, and connect string
            char[] split = { ';' };
            string[] parts = connect.Split(split, 3);
            if (parts.Length != 3)
            {
                // TODO: make this a real exception type
                throw new Exception("Malformed Inventory connection string '" + connect + "'");
            }

            dialect = parts[0];

            // NHibernate setup
            configuration = new Configuration();
            configuration.SetProperty(Environment.ConnectionProvider,
                            "NHibernate.Connection.DriverConnectionProvider");
            configuration.SetProperty(Environment.Dialect,
                            "NHibernate.Dialect." + dialect);
            configuration.SetProperty(Environment.ConnectionDriver,
                            "NHibernate.Driver." + parts[1]);
            configuration.SetProperty(Environment.ConnectionString, parts[2]);
            //configuration.SetProperty(Environment.ShowSql, "true");
            //configuration.SetProperty(Environment.GenerateStatistics, "false");
            //configuration.AddAssembly("WebDAVSharp.NHibernateStorage");
            configuration.AddAssembly("ModCableBeach");

        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:32,代码来源:NHibernateManager.cs

示例5: SessionFactory

        static SessionFactory()
        {
            var connectionString = @"Data Source=.\sqlexpress2014;Initial Catalog=BlogDatabase;Integrated Security=True";

            var configuration = new Configuration();
            configuration.DataBaseIntegration(
                x =>
                {
                    x.ConnectionString = connectionString;
                    x.Driver<SqlClientDriver>();
                    x.Dialect<MsSql2012Dialect>();
                });
            configuration.SetProperty(Environment.UseQueryCache, "true");
            configuration.SetProperty(Environment.UseSecondLevelCache, "true");
            configuration.SetProperty(Environment.CacheProvider, typeof(SysCacheProvider).AssemblyQualifiedName);
            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());

            mapper.BeforeMapBag += (modelInspector, member1, propertyCustomizer) =>
            {
                propertyCustomizer.Inverse(true);
                propertyCustomizer.Cascade(Cascade.All | Cascade.DeleteOrphans);
            };
            mapper.BeforeMapManyToOne +=
                (modelInspector, member1, propertyCustomizer) => { propertyCustomizer.NotNullable(true); };
            mapper.BeforeMapProperty += (inspector, member, customizer) => customizer.NotNullable(true);
            var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            configuration.AddMapping(mapping);
            sessionFactory = configuration.BuildSessionFactory();
        }
开发者ID:Nerielle,项目名称:Learning,代码行数:30,代码来源:SessionFactory.cs

示例6: TestAccount

 public static Boolean TestAccount(DatabaseAccountToken token, Boolean testMapping = false)
 {
     try
     {
         Configuration configuration = new Configuration();
         configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, token.ConnectionString);
         configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, String.Format("NHibernate.Driver.{0}", token.DatabaseDriver));
         configuration.SetProperty(NHibernate.Cfg.Environment.Dialect, String.Format("NHibernate.Dialect.{0}", token.DatabaseDialect));
         if (testMapping)
         {
             configuration.AddXml(token.Mapping);
             using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
             {
                 using (ISession session = sessionFactory.OpenSession())
                 {
                     return session.IsConnected;
                 }
             }
         }
         else
         {
             using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
             {
                 using (ISession session = sessionFactory.OpenSession())
                 {
                     return session.IsConnected;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
开发者ID:espressomorte,项目名称:Supakull,代码行数:35,代码来源:ClientNHibernateSessionFactory.cs

示例7: Configure

		protected override void Configure(Configuration configuration)
		{
			base.Configure(configuration);
			configuration.SetProperty(Environment.UseQueryCache, "true");
			configuration.SetProperty(Environment.CacheRegionPrefix, "criteriaquerytest");
			configuration.SetProperty(Environment.UseSecondLevelCache, "true");
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:7,代码来源:ReadOnlyCriteriaQueryTest.cs

示例8: ConfigureConnection

 private static void ConfigureConnection(Configuration configuration, string connectionString)
 {
     configuration.SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2005Dialect");
     configuration.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver");
     configuration.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
     configuration.SetProperty(Environment.ConnectionString, connectionString);
 }
开发者ID:MatthewLymer,项目名称:TodoApp,代码行数:7,代码来源:MsSqlSessionFactory.cs

示例9: Configure

		protected override void Configure(Configuration configuration)
		{
			configuration.SetProperty(Environment.UseSecondLevelCache, "false");
			configuration.SetProperty(Environment.UseQueryCache, "false");
			configuration.SetProperty(Environment.CacheProvider, null);
			configuration.SetListener(ListenerType.PostCommitDelete, new PostCommitDelete());
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:7,代码来源:Fixture.cs

示例10: Main

    static void Main()
    {
        Configuration nhConfiguration = new Configuration();

        nhConfiguration.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
        nhConfiguration.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.Sql2008ClientDriver");
        nhConfiguration.SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2008Dialect");
        nhConfiguration.SetProperty(Environment.ConnectionStringName, "NServiceBus/Persistence");

        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.CustomNhMappings.Default");
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.EnableInstallers();

        busConfiguration
            .UsePersistence<NHibernatePersistence>()
            .UseConfiguration(nhConfiguration);

        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            bus.SendLocal(new StartOrder
            {
                OrderId = "123"
            });

            bus.SendLocal(new CompleteOrder
            {
                OrderId = "123"
            });

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:34,代码来源:Program.cs

示例11: Configure

        protected override void Configure(Configuration configuration)
        {
            base.Configure(configuration);

            configuration.SetProperty("hibernate.search.default.directory_provider", typeof(FSDirectoryProvider).AssemblyQualifiedName);
            configuration.SetProperty(Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName);
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:7,代码来源:WorkerTestCase.cs

示例12: Configure

 protected override void Configure(Configuration configuration)
 {
     base.Configure(configuration);
     configuration.SetProperty("hibernate.search.default.directory_provider", typeof(Store.RAMDirectoryProvider).AssemblyQualifiedName);
     configuration.SetProperty(Environment.AnalyzerClass, typeof(Lucene.Net.Analysis.StopAnalyzer).AssemblyQualifiedName);
     configuration.SetProperty(Environment.WorkerScope, "transaction");
     configuration.SetProperty(Environment.WorkerExecution, "sync"); // Note: It is WorkerPrefix in the Java version, but it must be a typo
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:SyncWorkerTest.cs

示例13: Configure

		protected override void Configure(Configuration cfg)
		{
			base.Configure(cfg);
			cfg.SetProperty(Environment.ReleaseConnections, "after_transaction");
			//cfg.SetProperty(Environment.ConnectionProvider, typeof(DummyConnectionProvider).AssemblyQualifiedName);
			//cfg.SetProperty(Environment.GenerateStatistics, "true");
			cfg.SetProperty(Environment.BatchSize, "0");
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:8,代码来源:AggressiveReleaseTest.cs

示例14: CacheDisabled

		public void CacheDisabled()
		{
			Configuration cfg = new Configuration();
			cfg.SetProperty(Environment.UseSecondLevelCache, "false");
			cfg.SetProperty(Environment.UseQueryCache, "false");
			cfg.SetProperty(Environment.CacheProvider, null);
			cfg.BuildSessionFactory().Close();
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:8,代码来源:Fixture.cs

示例15: configurarSesiones

 public static void configurarSesiones()
 {
     cfg = new Configuration();
     cfg.SetProperty("dialect", "NHibernate.Dialect.MySQLDialect");
     cfg.SetProperty("connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
     cfg.SetProperty("connection.connection_string", "Server='" + servidor + "';Database='" + baseDatos + "';User ID=" + usuario + ";Password=" + pass + ";CharSet=utf8");
     cfg.AddAssembly("SIMO_CORE");
     sesiones = cfg.BuildSessionFactory();
 }
开发者ID:Gustav76,项目名称:SIMO_CORE,代码行数:9,代码来源:config.cs


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