解决办法通一个朋友了解到,错误是在配置文件里.
NHibernate 版本:1.2
配置文件写法:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<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=.;initial catalog=NHibernate;uid=sa;pwd=sa;Integrated Security=SSPI" />
<add key="hibernate.connection.isolation" value="ReadCommitted"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
</nhibernate>
</configuration>
运行通过,搞定。。。
不明白原因,请指教
MSN:foxrain59@hotmail.com
实体类
Person.cs
using System.Collections;
namespace Test.Model
{
Person#region Person
/**//// <summary>
/// Person object for NHibernate mapped table 'Person'.
/// </summary>
public class Person
{
Member Variables#region Member Variables
protected int _id;
protected string _name;
#endregion
Constructors#region Constructors
public Person() { }
public Person( string name )
{
this._name = name;
}
#endregion
Public Properties#region Public Properties
public int Id
{
get {return _id;}
set {_id = value;}
}
public string Name
{
get { return _name; }
set
{
if ( value != null && value.Length > 50)
throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
_name = value;
}
}
#endregion
}
#endregion
}
< hibernate - mapping xmlns = " urn:nhibernate-mapping-2.2 " >
< class name = " Test.Model.Person, Test.Model " table = " Person " >
< id name = " Id " type = " Int32 " unsaved - value = " null " >
< column name = " id " length = " 4 " sql - type = " int " not - null = " true " unique = " true " index = " PK_Person " />
< generator class = " native " />
</ id >
< property name = " Name " type = " String " >
< column name = " name " length = " 50 " sql - type = " varchar " not - null = " true " />
</ property >
</ class >
</ hibernate - mapping >