请教NHibernate 总出现Could not compile the mapping document [问题已搞定]

 

解决办法通一个朋友了解到,错误是在配置文件里.
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;
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

}
Person.hbm.xml
<? xml version = " 1.0 "  encoding = " utf-8 "   ?>
< 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 >

转载于:https://www.cnblogs.com/tt98/archive/2008/05/21/1204374.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值