zoukankan      html  css  js  c++  java
  • NHibernate 的序列化为了支持Web, 需要进行特定的配置.

     

    NHibernate 的序列化为了支持Web, 需要进行特定的配置, 吴伟的代码生成工具不能生成直接支持Web的配置文件. 

     /// <summary>配置初始化的封装</summary>

        public class DatabaseStarter : ActiveRecordStarter

        {

            static Type[] Types = new System.Type[] {

                            typeof(Ne),

                            typeof(NeCmdPort),

                            typeof(City),

                            typeof(Vendor),

                            typeof(NetElementType),

                            typeof(NeVirtualPort),

                            typeof(Role),

                            typeof(FunctionOperation),

                            typeof(CommandSet),

                            typeof(ResourceGroup),

                            typeof(Command),

                            typeof(RoleUser),

                            typeof(RoleUserGroup),

                            typeof(RoleResOperation),

                            typeof(RoleResCommandSet),

                            typeof(ResourceOperation),

                            typeof(SystemConfig)};

            static bool IsInitialized;

            /// <summary>Initialize database connection configuration.</summary>

            public static void Initialize(string connectionString)

            {

                if (DatabaseStarter.IsInitialized == false)

                {

                    lock (DatabaseStarter.Types)

                    {

                        StringReader reader = new StringReader(string.Format("<activerecord isWeb=""true"">       <config>            <add key=""hibernate.connection.driver class"" value=""NHibernate.Driver.SqlClientDriver""/>           <add key=""hibernate.dialect"" value=""NHibernate.Dialect.MsSql2000Dialect""/>         <add key=""hibernate.connection.provider"" value=""NHibernate.Connection.DriverConnectionProvider""/>          <add key=""hibernate.connection.connection_string"" value=""{0}""/>      </config>   </activerecord>", connectionString));

                        XmlConfigurationSource src = new XmlConfigurationSource(reader);

                        ActiveRecordStarter.Initialize(src, DatabaseStarter.Types);

                        DatabaseStarter.IsInitialized = true;

                    }

                }

            }

    }

     

  • 相关阅读:
    Android学习笔记【07】【四大组件之广播接收者】
    Android Adapter、Activity回传数据、发送短信
    Android学习笔记【06】【四大组件之Activity】
    Android学习笔记【05】【网络编程之二】
    Android学习笔记【04】【网络编程之一】
    Android学习笔记【03】【数据存储与数据展示】
    【转】sql server获取数据库名,表明,表结构
    C# 打开默认浏览器
    winform 重绘listbox
    字符串数组的简单应用,字符换行,c#,asp.net
  • 原文地址:https://www.cnblogs.com/dunnice/p/1085513.html
Copyright © 2011-2022 走看看