我有一个 asp.net 应用程序,并添加了一个包含我的域对象和 xml 文件的库。
痕迹是:
Message=Could not determine type for: VaLibrary.Core.Domain.VAEmpresa, VaLibrary, Version=1.0.5.18335, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(IdDev)
来源=NHibernate
我在网络上搜索同样的错误,但是,解决方案是针对其他映射选项(流利、城堡等)而不是针对 xml
我的代码课在这里
using System;
using System.Text;
using System.Collections.Generic;
namespace VaLibrary.Core.Domain {
public class VAEmpresa {
private int? _id;
private string _nombre;
private string _tipo;
public VAEmpresa() {
VAJu_Dev = new List<VAJu>();
VAJu_Pub = new List<VAJu>();
}
public virtual int Id {
get {
return (int)this._id;
}
set {
this._id = value;
}
}
public virtual string Nombre {
get {
return this._nombre;
}
set {
this._nombre = value;
}
}
public virtual string Tipo {
get {
return this._tipo;
}
set {
this._tipo = value;
}
}
public virtual IList<VAJu> VAJu_Dev { get; set; }
public virtual IList<VAJu> VAJu_Pub { get; set; }
}
}
参考是:
using System;
using System.Text;
using System.Collections.Generic;
namespace VaLibrary.Core.Domain {
public class VAJu {
private int? _id;
private VAEmpresa _idDev;
private VAEmpresa _idPub;
private VACon _vACon;
private string _titulo;
private int _numerop;
public VAJu() {
VApllist = new List<VApllist>();
}
public virtual int Id {
get {
return (int)this._id;
}
set {
this._id = value;
}
}
public virtual VAEmpresa IdDev {
get {
return this._idDev;
}
set {
this._idDev = value;
}
}
public virtual VAEmpresa IdPub {
get {
return this._idPub;
}
set {
this._idPub = value;
}
}
public virtual VACon VACon {
get {
return this._vACon;
}
set {
this._vACon = value;
}
}
public virtual string Titulo {
get {
return this._titulo;
}
set {
this._titulo = value;
}
}
public virtual int Numerop {
get {
return this._numerop;
}
set {
this._numerop = value;
}
}
public virtual IList<VApllist> VApllist { get; set; }
}
}
映射文件是:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="VaLibrary" namespace="VaLibrary.Core.Domain" xmlns="urn:nhibernate-mapping-2.2">
<class name="VAEmpresa" table="VA-Empresa" lazy="true" >
<id name="Id" column="Id">
<generator class="identity" />
</id>
<property name="Nombre">
<column name="nombre" sql-type="varchar" not-null="true" />
</property>
<property name="Tipo">
<column name="tipo" sql-type="varchar" not-null="false" />
</property>
<bag name="VAJu_Dev" inverse="true" cascade="none">
<key column="IdDev" />
<one-to-many class="VaLibrary.Core.Domain.VAJu, VaLibrary" />
</bag>
<bag name="VAJu_Pub" inverse="true" cascade="none">
<key column="IdPub" />
<one-to-many class="VaLibrary.Core.Domain.VAJu, VaLibrary" />
</bag>
</class>
</hibernate-mapping>
和
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="VaLibrary" namespace="VaLibrary.Core.Domain" xmlns="urn:nhibernate-mapping-2.2">
<class name="VAJu" table="VA-Ju" lazy="true" >
<id name="Id" column="Id">
<generator class="identity" />
</id>
<property name="Titulo">
<column name="Titulo" sql-type="varchar" not-null="true" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="IdDev">
<column name="IdDev" sql-type="int" not-null="true" />
</many-to-one>
<property name="IdDev">
<column name="IdDev" sql-type="int" not-null="true" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="IdPub">
<column name="IdPub" sql-type="int" not-null="true" />
</many-to-one>
<property name="IdPub">
<column name="IdPub" sql-type="int" not-null="true" />
</property>
<property name="Numerop">
<column name="numero-p" sql-type="int" not-null="true" />
</property>
<bag name="VApllist" inverse="true" cascade="none">
<key column="IdJu" />
<one-to-many class="VApllist" />
</bag>
</class>
</hibernate-mapping>
DB 中的关系是:Va-Ju.IdDev FK 到 VA-Empresa.Id PK Va-JU.IdPub FK 到 VA-Empresa.Id PK
我试图改变,但都是一样的。
我可以?
非常感谢您的回答
[编辑]
我使用休眠 3.2