title: Is there any Interdependent Collections Modifications Management Framework?
body: <p>Last day I ended up thinking about some collections interdependence.</p>
  
  <p>I cannot put a better label, name, title, or whatever suggesting this situation... so feel free to suggest anything better than my cheap labeling, that is " Interdependent Collections Modifications Management".</p>
  
  <p>Long story short, the example below.</p>
  
  <p>First, let's consider a couple of classes:</p>
  
  <pre><code>public class DummyItem
  {
      public DummyItem(String name)
      {
          this.Name = name;
      }
  
      public String Name { get; set; }
  }
  
  // A kind of repository of DummyItems
  public class BusinessClassProvider
  {
      public BusinessClassProvider()
      {
          this.Collection = new List&lt;DummyItem&gt;();
      }
  
      public IList&lt;DummyItem&gt; DummyItems{ get; private set; }
  }
  
  public class BusinessClassConsumer
  {
      public BusinessClassConsumer()
      {
          this.Collection = new Collection&lt;DummyItem&gt;();
      }
  
      public ICollection&lt;DummyItem&gt; DummItems{ get; private set; }
  }
  </code></pre>
  
  <p>Now let's say that BusinessClassProvider.Collection is populated via some processes, user inputs, etc. </p>
  
  <p>The BusinessClassConsumer Collection is something selected from BusinessClassProvider Collection by let's say also some user inputs or any other way.</p>
  
  <p>Now if I remove or add a DummyItem from the BusinessClassProvider Collection I need to create Additional Nethods to wrap  or eventually if they are some events supported to notify the others of what have been changed and remove accordingly the related other Collections (e.g. BusinessClassConsumer one) to also remove this item. 
  Basically it means a lot of boilerplate code and a lot of stuff to handle manually.</p>
  
  <p>Of course, we could go with another strategy using IEnumerable as BusinessClassConsumer Collection but it does not provide the same options about indexing for instance, furthermore it forces to iterate over and over on BusinessClassProvider Collection.</p>
  
  <p>I know it raises many more questions like which collection is kinda the provider and the others which consumes from.</p>
  
  <p>Is there any frameworks via Attributes, or any other nasty tricks to enforce the dependency between several collections?</p>
  
  <p>By the way, once again, is there anybody who knows how to label correctly this sort of situation?</p>