开发者

How to include multiple columns in a many to many relationship with nhibernate?

I have the following DB schema:

Users
-Id (uniqueidentifier)
-FirstName
-LastName
-Email

AuthProviders
-Id (smallint)
-Name

UserAuthProviders
-Id (uniqueidentifier)
-User (uniqueidentifier, FK)
-AuthProvider (smallint, FK)
-Identity (nvarchar)

I need to map all AuthProviders to the User object. I started with an idbag, but it looks like that only allows me to have an Id开发者_StackOverflow中文版, User relationship, and AuthProvider relationship. I need to be able to include the Identity as well.

What else can I use to map it?


You need to use a many-to-one and a one-to-many, which ends up with 3 classes instead of two. You can eliminate the joining class from your public API, but you'll still have to deal with it in the POCO class internals.

A more complete answer can be found here:

NHibernate many-to-many - how to retrieve property from join table and associate it with a child?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜