2012-04-24 22 views
1

私はLoquacious Nhibernateでマップしようとしている2つのクラスがあります。Loquacious Nhibernateと複合ID外部キー

マッピングは、以下の

public class FooMap : ClassMapping<Foo> 
    { 
    Table("FooTableName"); 
    ComposedId(compIDMapper => 
     { 
     compIDMapper.Property(x => x.SomeInt, m => m.Column("SomeInt")); 
     compIDMapper.ManyToOne(x => x.SomeReference, m => m.Column("SomeReference")); 
     }); 
    } 

    public class BarMap : ClassMapping<Bar> 
    { 
    Table("BarTableName"); 
    Id(x => x.ID, m => m.Column("barID")); 

    ManyToOne(x => x.Foo, m => m.Columns(columnMapper => 
                  { 
                   columnMapper.Name("SomeIntID"); //Both of these columns are in the BarTableName like they should be 
                   columnMapper.Name("SomeReferenceID"); 
                  })); 
    } 

のようなものです。しかしマッピングが、私は次のエラーを取得する構築されているとき:

Foreign key (FK554EAF2427B2CA28:BarTableName[SomeIntID])) must have same number of columns as the refe,renced primary key (FooTableName[SomeInt, SomeReference]) 

は私が間違ってやっているかわからないんだけど、それをそれはうまくいくように見えますが、私はこれで私の頭をしばらく叩いていて、どこにも手を入れていません。私が間違っていることに関するアイデアは?

答えて

1

最後にこれを見つけ出し、他の誰かがこれを投稿しました。

私の問題は、列マッパーを誤解していました。それは次のようなものです:

ManyToOne(x => x.Foo, m => m.Columns(new Action<IColumnMapper>[] 
                   { 
                    colMapper => colMapper.Name("SomeIntID"), 
                    colMapper => colMapper.Name("SomeReferenceID") 
                   })); 

これは問題を解決しました。関数のシグネチャを見たときに気づいたはずですが、私は完全にそれを逃しました。

関連する問題