0

특성 관계를 사용하여 many to many 매핑에 문제가 있습니다. 대신이 다른 두 종류의 ID가 구성되어 여기에 문제많은 수의 특성으로 매핑 - 기본 키가 외래 키입니다.

fluent nhibernate - Many to Many mapping with attribute

하지만 내 중산층에 기본 키가없는 같은 많은.

견적 SKU 클래스 (중산층)

public class QuotationSKUCost : Entity 
{ 
    public virtual decimal UnitPrice { get; set; } 
    public virtual Quotation Quotation { get; set; } 
    public virtual QuotationRequestSKU QuotationRequestSKU { get; set; } 
} 

견적 클래스

public class Quotation : Entity 
{ 
    public virtual int Id { get; set; } 
    public virtual DateTime ValidUntil { get; set; } 
    public virtual string Data { get; set; } 
    public virtual ICollection<QuotationSKUCost> QuotationSKUCosts { get; set; } 
} 

견적 요청 SKU

public class QuotationRequestSKU : Entity 
{ 
    public virtual int Id { get; set; } 
    public virtual int Quantity { get; set; } 
    public virtual ICollection<QuotationSKUCost> QuotationSKUCost { get; set; } 
} 

중산층 매핑!

public QuotationSKUCostMapping() 
    { 
     Table("QuotationSKUCost"); 
     CompositeId() //need to map QuotationId and QuotationRequestSKUid as Composite key 
      .KeyProperty(x => x.Quotation, "QuotationId") 
      .KeyReference(x => x.QuotationRequestSKU, "QuotationRequestSKUId"); 
     Map(x => x.UnitPrice); 
    } 

디버깅하려고 할 때 나는 점점 오전 오류는 다음과 같습니다

에 대한 유형을 결정 할 수 없습니다 : ORM.Entities.Quote.Quotation을, ORM, 버전 = 1.0.0.0, 문화 = 컬럼 중립 PublicKeyToken은 = NULL : NHibernate.Mapping.Column (QuotationId)

EDIT : 인용 (MA)를 추가

public QuotationMapping() 
    { 
     Id(x => x.Id).Column("QuotationId"); 
     Map(x => x.ValidUntil); 
     Map(x => x.Data); 
     HasMany(x => x.QuotationSKUCosts).KeyColumn("QuotationId"); 
    } 
+0

당신의'Quotation' 클래스의 구성이 무엇이어야한다 찾고 후 답을 찾을 수 pping? – Guillaume

+0

견적 매핑을 추가했습니다. – Steve

답변

0

훨씬

  .KeyProperty(x => x.Quotation, "QuotationId") 
      .KeyReference(x => x.QuotationRequestSKU, "QuotationRequestSKUId"); 

  .KeyReference(x => x.Quotation, "QuotationId") 
      .KeyReference(x => x.QuotationRequestSKU, "QuotationRequestSKUId"); 
관련 문제