【NH笔记一】.config配置介绍

一. 先来看一下配置文件 .config 的几点

<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<!--Addthiselement-->
<configSections>
</configSections>

<!--Addthiselement-->xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<propertyname="dialect">NHibernate.Dialect.Mssql2005Dialect</property>
<propertyname="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<propertyname="connection.connection_string">Server=localhost\sqlEXPRESS;initialcatalog=quickstart;IntegratedSecurity=True</property>
</session-factory>
</hibernate-configuration>
</configuration>

这是官方给出的配置代码,如果你采用MSsqlEXPRESS的话,这个可以使用使用,其他的没有列出的配置都采用认配置(这些配置以后用到了会慢慢介绍),其中有几点需要注意的地方:
<sectionname="hibernate-configuration"type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate"/>这句话的意思:
  name对应着一个配置节<hibernate-configuration>,type对应着解析<hibernate-configuration>的类,一般照搬写死就OK了。

2.<mappingassembly="QuickStart"/>的含义:指定你持久类映射文件的程序集,这个和持久类映射文件中的配置是相呼应的,如下:
其实这样写也是可以的,就是把命名空间和程序集放在class配置节上。

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念