title: Advice on an ActiveRecord design pattern in C#
body: <p>I'm in the process of writing a BSD licensed mini-ORM targeted at embedded databases (with support for ese, sqlite and sqlce out of the box) </p>
  
  <p>After working lots with Rails in the last year I have been thinking of implementing an Active Record pattern in C#. </p>
  
  <p>I have come up with some demo code and was wondering if the interface design is sound.</p>
  
  <p>Here you go:</p>
  
  <pre><code>// first param is the class, second is the primary key
  public class Order : ActiveRecord&lt;Order,int&gt; {
      BelongsTo&lt;Customer&gt; Customer { get; set; }
  
      [PrimaryKey(AutoIncrement=true)]
      public int Id { get; set; }
  
      public string Details { get; set; }
  } 
  
  
  [Index("FirstName", "LastName")]
  [Index("LastName", "FirstName")] 
  public class Customer : ActiveRecord&lt;Customer,int&gt; 
  {
  
      public HasMany&lt;Order&gt; Orders { get; set; }
  
      [PrimaryKey(AutoIncrement=true)]
      public int Id { get; set; }
  
      [ColumnInfo(MinLength=4, MaxLength=255, Nullable=false)]
      public string FirstName { get; set; }
  
      [ColumnInfo(MinLength=4, MaxLength=255, Nullable=false)] 
      public string LastName { get; set; }
  
      public string Comments { get; set; }
  }
  
  [TestClass]
  public class TestActiveRecord {
  
      public void Demo() 
      {
          var customer = Customer.Build();
          customer.FirstName = "bob";
          customer.LastName = "doe";
  
          var order = customer.Orders.Build();
          order.Details = "This is the first order"; 
          customer.Save();
  
          var customer2 = Customer.Find(customer.Id);
  
          Assert.AreEqual(1, customer2.Orders.Count); 
      }
   }
  </code></pre>
  
  <p>Sorry about this being a multiple questions in one question ...
  Can you think of any changes to this API? Are there any fatal flaws? Are there any open source ORMs that define similar interfaces?   </p>