Many to Many relationship between objects - The best way to implement

  • Thread starter Thread starter solex
  • Start date Start date
S

solex

Sasha,

The same way you would with a database, create an intermediate object that
relates the two objects.

Dan
 
That is a good question. In my case I have Parties that can be related to
other parties via a PartyRelation object. I made a decision to make the
relationships directional, so that one party actually owns the relationship.

In my case it is up to the application to create the link or destory it.

Dan
 
Hi everyone,

What is the best way to implement many-to-many relationship between objects?
Any examples or links are welcome!

Thank you,
Sasha
 
Thank you for the answer Solex,

But who would be responsible for creating the link object, or destroying it?
I am trying to keep my model loosly coupled...
 
Sasha,
In addition to Solex's suggestion.

Simply have each object own (contain) a collection of the other object. This
collection could be any .NET collection, such as: an array, ArrayList,
HashTable, or a collection derived from CollectionBase or DictionaryBase.

If you are coming from a database, then the Association Table Mapping
Pattern may be more helpful.

http://www.martinfowler.com/eaaCatalog/associationTableMapping.html

Hope this helps
Jay
 
Back
Top