惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tor Project blog
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
I
InfoQ
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
人人都是产品经理
人人都是产品经理
美团技术团队
B
Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
TaoSecurity Blog
TaoSecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Threatpost
H
Heimdal Security Blog
爱范儿
爱范儿
博客园_首页
SecWiki News
SecWiki News
腾讯CDC
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
The Register - Security
The Register - Security
N
News | PayPal Newsroom
Recent Commits to openclaw:main
Recent Commits to openclaw:main
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Security Latest
Security Latest
A
Arctic Wolf
P
Privacy & Cybersecurity Law Blog
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
量子位
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
Attack and Defense Labs
Attack and Defense Labs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
C
Check Point Blog
Y
Y Combinator Blog
T
The Exploit Database - CXSecurity.com
aimingoo的专栏
aimingoo的专栏
I
Intezer
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
小众软件
小众软件

博客园 - thh

svm资料收集 向量空间及其他相关数学结构 难题--autoconf、automake、libtool Linq 中不爽之处 关于UI设计的文章汇总 Window Live Writer LR 剖析器 MVP模式中的P和V关系 Guid、Int、BigInt编号的速度和存储空间的比较 静态构造函数线程安全的几个版本[转载] 区域性 ID 2155 (0x086B)不是受支持的区域性 解决方法 windbg给clr设置断点 python ip和int 互转函数 interface与pojo类之间的关系 关于OpenId Python SOAPpy访问asp.net web service 代码 Python SOAPpy 和 .net WebService Type.GetType 获得本Assembly以外的类型 NHibernate 代码生成工具
NHibernate使用笔记
thh · 2007-03-13 · via 博客园 - thh

      最近看了好多ORM库,自己也尝试过自己写一些代码,终于还是决定使用 NHibernate。至于具体的使用,过去不是很了解,所以也是从头开始。
      从sf下载bin和source 包,把它们放到对应的位置,开始一个新的探索过程了。对于网上的很多文章和附带的文档,感觉很难把握要领。所以先从nhibernate的附带的example开始,并学习在web项目中使用它。一边学一边用,也许是个不错的方法。

      创建一个空的web项目,第一目录是要在这个项目中使用NHibernate,配置库,添加引用是开始。添加引用比较简单,直接复制文件或者通过ide添加引用到bin目录后,就基本完成。接下来要配置web.config了。看了帮助用的QuickStart,添加如下内容,基本上也就算完成了。

  <configSections>
    
<section name="hibernate" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  
</configSections>

  
<hibernate xmlns="urn:nhibernate-configuration-2.2">
    
<session-factory>
      
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
      
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      
<property name="connection.connection_string">Server=(local);Initial Catalog=xxxx;Persist Security Info=True;User ID=xxxx;Password=xxxx</property>

      
<mapping assembly="QuickStart" />
    
</session-factory>
  
</hibernate>

    

   配置完后,开始了解NHibernate是在那些位置被使用的。

   debug example的项目,在vs2005里看看执行的过程。 程序首先执行到了static ExampleApplication()

      log4net.Config.XmlConfigurator.Configure();
   Configuration 
= new NHibernate.Cfg.Configuration()
    .SetDefaultAssembly(
typeof(Item).Assembly.FullName)
    .SetDefaultNamespace(
typeof(Item).Namespace)
    .AddDirectory(
new DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/")));
   
   SessionFactory 
= Configuration.BuildSessionFactory();

    这个部分是执行程序初始化配置的,具体的用法,现在需要看一下附带的help文件了(Chapter 3. ISessionFactory Configuration--- 3.1. Programmatic Configuration)。  http://www.cnblogs.com/abluedog/archive/2006/04/17/377630.html  这个系列里有不少的介绍。现在正在了解 “在取得config后,我们还需要进行映射文件添加”这个部分。但是新版的添加方式已经增加了,可以看看NHibernate.Cfg.Configuration.Addxxxx类的方法。