title: DDD: How to check invariant with multiple aggregate
body: <p>I know that keeping large collections in Aggregates impacts performance.</p>
  <p>In my use case i have <strong>STORE</strong> which can have multiple <strong>PRODUCT</strong> and each product can have <strong>CUSTOMIZATION</strong>(Not more than 10-20 customization).</p>
  <p>I thought of creating one store aggregate only and update product and customization through it but as product collection can be large so it will impact performance. So I have two aggregates <strong>STORE</strong>(to create store) and <strong>PRODUCT</strong>(with storeId,all product operation) with this approach I am not able to check if product already exist or not.</p>
  <p>what i am doing now is getting all products by StoreId in my handler and checking duplicate which is not right way as it should belong to my domain model.</p>
  <p>Anyone has better idea to solve this.
  below are my domain models.</p>
  <pre><code>public class Store : Entity&lt;Guid&gt;, IAggregateRoot
      {
          private Store()
          {
              this.Products = new List&lt;Product&gt;();
          }
          private Store(string name, Address address) : base(System.Guid.NewGuid())
          {
              
              this.Name = name;
              this.Address = address;
          }
          private Store(string name, Address address, ContactInfo contact) : this(name, address)
          {
             
              this.Contact = contact;
          }
          public string Name { get; private set; }
          public Address Address { get; private set; }
          public ContactInfo Contact { get; private set; }
      }
  </code></pre>
  <pre><code> public class Product : Entity&lt;Guid&gt;, IAggregateRoot
      {
          private Product()
          {
  
          }
          private Product(Guid storeId, ProductInfo productInfo) : base(Guid.NewGuid())
          {
              
              this.ProductInfo = productInfo;
              this.StoreId = storeId;
              this.Customizations = new List&lt;Customization&gt;();
          }
          private Product(Guid storeId, ProductInfo productInfo, IEnumerable&lt;Customization&gt; customizations) : this(storeId, productInfo)
          {
              
              this.Customizations = customizations;
          }
  
          public ProductInfo ProductInfo { get; private set; }
  
          private List&lt;Customization&gt; _customizations;
          public IEnumerable&lt;Customization&gt; Customizations
          {
              get
              {
                  return _customizations.AsReadOnly(); 
              }
              private set
              {
                  _customizations = (List&lt;Customization&gt;)value;
              }
          }
          public Guid StoreId { get; private set; }
  
          public static Product Create(Guid storeId, ProductInfo productInfo)
          {
              return new Product(storeId, productInfo);
          }
  
          public void UpdateInfo(ProductInfo productInfo)
          {
              this.ProductInfo = productInfo;
          }
  
          public void AddCustomization(Customization customization)
          {
              
              this._customizations.Add(customization);
          }
  
          public void RemoveCustomization(Customization customization)
          {
            
  
              this._customizations.Remove(customization);
          }
      }
  </code></pre>