title: Deleting object from collection Domain Driven Design
body: <p>In our project we are following Domain Driven Design with entity framework. Recently i came upon one issue where i want to delete a object from collection . Lets say Customer have collection of purchase. I want to remove the particular purchase of one customer.</p>
  
  <pre><code> public class Customer
  {
      public int ID { get; set; }
  
      public string Name { get; set; }
  
      public string Address { get; set; }
  
      public virtual ICollection&lt;Purchase&gt; Purchases { get; set; }
  }
  
  public class Purchase
  {
      public int ID { get; set; }
  
      public int CustomerId { get; set; }
  
      public DateTime PurchaseDate { get; set; }
  }
  </code></pre>
  
  <p>I tried to remove the purchase by </p>
  
  <pre><code>customer.Purchases.Remove(purchase);
  </code></pre>
  
  <p>but the above code removed only the relation not deleting the purchase from db . I want to remove them from db.</p>
  
  <p>So to make that work i have given that responsibility to Repository and used context object inside repository to remove the purchase.</p>
  
  <pre><code>repository.DeletePurchase(purchase);
  </code></pre>
  
  <p>Is the above is right approach in Domain Driven Design or any possibilities to move the delete behavior within entity?</p>
  
  <p>Pleas help me the follow the best practice to implement DDD.</p>