public class user
{
private string id;
public virtual string LogOnID
{
get { return id; }
set { id = value; }
}
private string _name;
public virtual string name
{
get { return _name; }
set { _name = value; }
}
private string _Password;
public virtual string Password
{
get { return _Password; }
set { _Password = value; }
}
private string _Emailadress;
public virtual string Emailadress
{
get { return _Emailadress; }
set { _Emailadress = value; }
}
private DateTime? _Lastlogon;
public virtual DateTime? Lastlogon
{
get { return _Lastlogon; }
set { _Lastlogon = value; }
}
映射文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="YangTest.Entity.user,YangTest.Entity" table="users" lazy="true">
<id name="LogOnID" column="LogOnID" type="String">
<generator class="assigned"/>
</id>
<property column="name" type="String" name="name" length="40" />
<property column="Password" type="String" name="Password" length="20" />
<property column="Emailadress" type="String" name="Emailadress" length="40" />
<property column="Lastlogon" type="DateTime" name="Lastlogon" />
</class>
</hibernate-mapping>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,
Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Server=192.168.0.106;database=YangTest;uid=sa;pwd=xinwei"
/>
<add
key="hibernate.connection.isolation"
value="ReadCommitted"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<add key="show_sql" value="true"/> //这里是看的别人的一个帖子,可以监视sql语句
</nhibernate>
我是直接写在web.config里头的,没有单独建一个config。