初学NHibernate,NHibernate B/S C/S 初级的项目源码
NHibernate通过方言(dialect)来消除这些这些开源或者是商业数据库之间对SQL标准的解释的差异。
NHibernate对属性使用的类型不加任何限制。为了让上面提到运行时类增强功能生效,NHibernate持久化类的所有的public的属性必须声明为virtual。
它独立的使用.Net反射机制和运行时类增强(通过Castle.DynamicProxy2 library)。
创建使用的表UserInfo
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserInfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserInfo](
[ID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [varchar](50) NOT NULL,
[Age] [int] NULL,
[Address] [varchar](50) NULL,
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
NHibernate B/S 初级的项目源码下载:NHibernateBSApp.rar
注意:下载后修改标出的连接字符串
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">
Server=WS2003;initial catalog=NHibernate;Integrated Security=SSPI;user id=sa;password=sa;
</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<mapping assembly="NHibernateAppModel"/>
</session-factory>
</hibernate-configuration>
NHibernate C/S 初级的项目源码:NHibernateCSApp.rar
一步一步自学,发现世界前进了,自己倒退了,XXOO