當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。