當保存我的多對多關聯實體時,實體將保存成功。然而結合表保持爲空:fluentnhibernate ManyToMany不會將記錄添加到聯結表
上產品側映射(ProductMap.cs)
HasManyToMany(x => x.Pictures)
.Table("Product_Picture")
.ParentKeyColumn("Product")
.ChildKeyColumn("Picture")
.Cascade.All()
.Inverse()
這將產生以下的xml:上側圖片
<bag cascade="all" name="Pictures" table="Product_Picture">
<key>
<column name="Product" />
</key>
<many-to-many class="...Picture...">
<column name="Picture" />
</many-to-many>
</bag>
映射(PictureMap.cs)
HasManyToMany(x => x.Products)
.Table("Product_Picture")
.ParentKeyColumn("Picture")
.ChildKeyColumn("Product")
.Cascade.All();
這產生以下xml:
<bag inverse="true" cascade="all" name="Products" table="Product_Picture">
<key>
<column name="Picture" />
</key>
<many-to-many class="...Product...">
<column name="Product" />
</many-to-many>
</bag>
任何想法?
在啓動代碼塊之前,您需要一個空白行。 – 2010-05-28 14:11:24
好的謝謝:),現在我只需要一個問題的答案 – Bertvan 2010-05-28 14:24:05
正如我所建議的,我們將需要看到更多的代碼... – 2010-05-28 15:42:08