开发者

Fluent NHibernate - Many To Many Relationship

开发者 https://www.devze.com 2023-01-08 02:20 出处:网络
I have Product and Category tables in database. One product can have many categories. One category c开发者_运维知识库an have many products.

I have Product and Category tables in database.

One product can have many categories.

One category c开发者_运维知识库an have many products.

So, I have a third table as ProductCategory, which has ProductID and CategoryID.

In Fluent NHibernate, what should the mapping class look like?

For example, For ProductMap class is this correct:

HasMany(x => x.Categories).Table("tProductCategory").KeyColumn("CategoryId);


Take a look: https://stackoverflow.com/questions/108396?tab=newest#tab-top

See the question, see the responses. The problem is solved and you will learn why the inverse is important. Also using fluent you will need only to map the one side, not both.

0

精彩评论

暂无评论...
验证码 换一张
取 消