title: How do I populate my domain model from my repository if my properties have private setters?
body: <p>In the domain core of my application, I have an <code>Order</code> object. It has private setters, since those properties should not be modified willy-nilly, but only within the context of performing one of the public functions on the object.</p>
  
  <pre><code>public class Order
  {
      public int Id { get; private set; }
      public int MarketplaceId { get; private set; }
      public int CustomerId { get; set; }
      public OrderStatus Status { get; private set; }
  
      public bool Validate() { //stuff }
      public void Fulfill()
      {
          //messes with order status, etc.
      }
  
  }
  </code></pre>
  
  <p>I have an <code>OrderRepository</code> for data access, which lives on the outer edges of my architecture, which has a <code>GetOrderById(int orderId)</code> function. This function pulls from the database to populate an <code>Order</code> object. I need to be able to populate my <code>Order</code> object, but I'd rather not expose the properties as public, since any other application or service utilizing the <code>Order</code> object should not be setting those properties. How can I architect this to populate the <code>Order</code> object from the repository but still retain my encapsulation on the <code>Order</code> object?</p>
  
  <p>It seems like doing this through one or more constructors (overloads) would be messy, but I'm not sure what else to do.</p>