Hi all,

I have a question concerning Relations in NHibernate.
To illustrate my question, here's an example:

class Category
{
   public int Id {get; set;}
   public string Name {get; set;}
   public IList<Product> Products{get; set;}
}

class Product
{
   public int Id {get; set;}
   public string Name {get; set;}
   public IList<Category> Categories{get;set;}
}

Please imagine these classes fully mapped. Using Bags and OneToMany-
Relations, you could get NHibernate to create the desired relation
between them. What I basically do is the following:

Category c1 = new Category(){Id=1, Name="Games"};
Product p1 = new Product(){Id=1, Name="SomeDumbGame"};
p1.Categories.Add(c1);

Talking about Domain objects, everything is as it is supposed to be.
But when observing the relational side of this, the mappings are now
incomplete, since c1.Products does not contain p1.

Is there a way of refreshing those relations automatically in
NHibernate? Or would I have to create convenience Methods like
Category.AddProduct or Product.AddCategory that both do the same :
Update both lists. It's a bit of a bugger in case your Data Model gets
a bit more extensive...

Any help appreciated! Thanks in advance

Sebi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to