views:

67

answers:

1

Hi,

I have a pretty simple data model.

Article (ID, name, body, date) Category (ID, name, count)

Article_Category (articleID, categoryID)

Comment (ID, articleID, name, body, date)

How would I go about laying out my nhibernate mapping?

Also, when I create a new article, it will only have the article and the ID of the category to associate it to. How would it persist to the database in this scenerio?

+1  A: 

For the Article and Category example you need to check out many-to-many mapping and load vs. get.

Many-to-many (6.1 to 6.3 in documentation):

http://www.nhforge.org/doc/nh/en/index.html#collections-mapping

http://www.nhforge.org/doc/nh/en/index.html#collections-ofvalues

load (9.2 in documentation):

http://www.nhforge.org/doc/nh/en/index.html#manipulatingdata-loading

For comment it sounds like a simple one-to-many would work, and a good reading of chapter 6 would help.

eyston