사용하여 DB 테이블에 열거 형의 목록이 클래스를 매핑해야
여기 -------------- 객체
public class Driver : IIdentity
{
private IList<Licence> licences;
/// <summary>
/// The drivers licences
/// </summary>
public virtual IList<Licence> Licences
{
get
{
return this.licences;
}
set
{
this.licences = value;
}
}
..... rest of the class ....
}
//the enum
public enum Licence
{
FivePersonCar = 5,
SixPersonCar = 6
}
있습니다 - 여기 여기 ------------- DB를 테이블
TABLE [dbo].[DriverLicence]( [DriverId] [int] NOT NULL, [Level] [int] NOT NULL)
TABLE [dbo].[Driver]( [DriverId] [int] NOT NULL, [Name] [varchar](150) NULL)
이다 D에 대한 내 유창함지도입니다 강
public class DriverMap : ClassMap<Driver>
{
public DriverMap()
{
Id(x => x.Id).WithUnsavedValue(0).GeneratedBy.Identity();
Map(x => x.Name);
HasManyToMany(x => x.Licences)
.WithTableName("DriverLicence")
.AsElement("Level").AsBag();
HasManyToMany(x => x.InsuredToDrive)
.CollectionType<InsurancedList>()
.WithTableName("InsuredWith");
}
}
는 -----이 다음 HBM 파일을 생성
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="">
<class name="Taxi.DomainObjects.Driver, Taxi.DomainObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`Driver`" xmlns="urn:nhibernate-mapping-2.2">
<id name="Id" type="Int32" unsaved-value="0" column="DriverID">
<generator class="identity" />
</id>
<property name="Name" type="String">
<column name="Name" />
</property>
<bag name="Licences" table="DriverLicence">
<key column="DriverId" />
<many-to-many column="LicenceId" class="Taxi.DomainObjects.Licence, Taxi.DomainObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
<bag name="InsuredToDrive" collection-type="Taxi.DomainObjects.Collections.InsurancedList, Taxi.DomainObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="InsuredWith">
<key column="DriverId" />
<many-to-many column="CarId" class="Taxi.DomainObjects.Car, Taxi.DomainObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
</class>
</hibernate-mapping>
여기
내 오류가
"테이블 DriverLicence에서 연관이 매핑되지 않은 클래스를 의미한다 : Taxi.DomainObjects.Licence "
아무도 내가 잘못하고있는 것을 알고 있습니까?
hasMany의 (X => x.Licences) .WithTableName ("DriverLicence") .AsElement ("레벨")를 떠났다.AsBag(); – dbones