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

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
博客园_首页
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
罗磊的独立博客
V
Visual Studio Blog
Know Your Adversary
Know Your Adversary
Hacker News - Newest:
Hacker News - Newest: "LLM"
美团技术团队
L
LINUX DO - 最新话题
The Last Watchdog
The Last Watchdog
博客园 - 三生石上(FineUI控件)
T
Tor Project blog
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
I
InfoQ
Last Week in AI
Last Week in AI
V2EX - 技术
V2EX - 技术
量子位
S
Secure Thoughts
L
LangChain Blog
The Hacker News
The Hacker News
H
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
K
Kaspersky official blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
I
Intezer
Vercel News
Vercel News
Hacker News: Ask HN
Hacker News: Ask HN
Cisco Talos Blog
Cisco Talos Blog
Google DeepMind News
Google DeepMind News
S
Securelist
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
Help Net Security
Help Net Security
Martin Fowler
Martin Fowler
爱范儿
爱范儿
Y
Y Combinator Blog
C
Check Point Blog

博客园 - 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类的方法。