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


C# Configuration.BuildMapping方法代码示例

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


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

示例1: InitalizeSessionFactory

        public static void InitalizeSessionFactory(params FileInfo[] hbmFiles)
        {
            if (SessionFactory != null)
                return;

            var properties = new Dictionary<string, string>
                                 {
                                     {"connection.driver_class", "NHibernate.Driver.SQLite20Driver"},
                                     {"dialect", "NHibernate.Dialect.SQLiteDialect"},
                                     {"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
                                     {"connection.connection_string", "Data Source=askme.db;Version=3;New=True;"},
                                     {"connection.release_mode", "on_close"},
                                     {"show_sql", "true"},
                                     {"proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"}
                                 };

            Config = new Configuration {Properties = properties};

            foreach (FileInfo mappingFile in hbmFiles)
            {
                Config = Config.AddFile(mappingFile);
            }
            Config.BuildMapping();
            SessionFactory = Config.BuildSessionFactory();
        }
开发者ID:karthikbv,项目名称:askme,代码行数:25,代码来源:NHibernateInMemoryBase.cs

示例2: 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

示例3: InitalizeSessionFactory

        public static void InitalizeSessionFactory()
        {
            if (sessionFactory != null)
                return;

            var properties = new Dictionary<string, string>();
            properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver,NHibernate");
            properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
            properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            properties.Add("connection.connection_string", "Data Source=./../../../database/gringotts.db;Version=3;New=True;");
            properties.Add("connection.release_mode", "on_close");
            properties.Add("show_sql", "true");

            configuration = new Configuration();
            configuration.Properties = properties;
            configuration.AddAssembly("Gringotts");

            configuration.BuildMapping();
            sessionFactory = configuration.BuildSessionFactory();
        }
开发者ID:bagheera,项目名称:Gringotts,代码行数:20,代码来源:NHibernateInMemoryTestFixtureBase.cs

示例4: InitalizeSessionFactory

        public static void InitalizeSessionFactory(params FileInfo[] hbmFiles)
        {
            if (sessionFactory != null)
                return;

            var properties = new Dictionary<string, string>();
            properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
            properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
            properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            properties.Add("connection.connection_string", "Data Source=../../../database/getin.db;Version=3");
            properties.Add("connection.release_mode", "on_close");
            properties.Add("show_sql", "true");

            configuration = new Configuration();
            configuration.Properties = properties;

            foreach (FileInfo mappingFile in hbmFiles)
            {
                configuration = configuration.AddFile(mappingFile);
            }
            configuration.BuildMapping();
            sessionFactory = configuration.BuildSessionFactory();
        }
开发者ID:bagheera,项目名称:getin,代码行数:23,代码来源:NHibernateFixtureBase.cs

示例5: InitalizeSessionFactory

        public static void InitalizeSessionFactory(params Assembly[] assemblies)
        {
            if (sessionFactory != null)
                return;

            var properties = new Dictionary<string, string>();
            properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
            properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
            properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
            properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            properties.Add("connection.connection_string", "Data Source=:memory:;Version=3;New=True;");
            properties.Add("connection.release_mode", "auto");
            properties.Add("show_sql", "true");

            configuration = new Configuration();
            configuration.Properties = properties;

            foreach (Assembly assembly in assemblies)
            {
                configuration = configuration.AddAssembly(assembly);
            }
            configuration.BuildMapping();
            sessionFactory = configuration.BuildSessionFactory();
        }
开发者ID:habib,项目名称:AnujBank,代码行数:24,代码来源:NHibernateInMemoryTestFixtureBase.cs


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