title: Design pattern for saving entities into database
body: <p>I have a class similar to the below (C#):</p>
  
  <pre><code>public class Product {
  
      public int ID {get;set;}
      public string Name {get;set;}
      public double Price {get;set;}
  
      public void Save() {
          string sql = "INSERT INTO Product.....";
          Database.Execute(sql);
      }
  
      public void Delete() {
          string sql = "DELETE Product WHERE.....";
          Database.Execute(sql);
      }
  }
  </code></pre>
  
  <p>My main concern is that the code above violates SOLID principles, since it takes responsibility for creating and deleting itself.</p>
  
  <p>Perhaps these Save and Delete methods should be placed somewhere outside the Product entity (Factory/Repository maybe?).</p>