title: If you are forced to use an Anemic domain model, where do you put your business logic and calculated fields?
body: <p>Our current O/RM tool does not really allow for rich domain models, so we are forced to utilize anemic (DTO) entities everywhere.  This has worked fine, but I continue to struggle with where to put basic object-based business logic and calculated fields.</p>
  
  <p>Current layers:</p>
  
  <ul>
  <li>Presentation </li>
  <li>Service </li>
  <li>Repository</li>
  <li>Data/Entity</li>
  </ul>
  
  <p>Our repository layer has most of the basic fetch/validate/save logic, although the service layer does a lot of the more complex validation &amp; saving (since save operations also do logging, checking of permissions, etc).  The problem is where to put code like this:</p>
  
  <pre><code>Decimal CalculateTotal(LineItemEntity li)
  {
    return li.Quantity * li.Price;
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>Decimal CalculateOrderTotal(OrderEntity order)
  {
    Decimal orderTotal = 0;
    foreach (LineItemEntity li in order.LineItems)
    {
      orderTotal += CalculateTotal(li);
    }
    return orderTotal;
  }
  </code></pre>
  
  <p>Any thoughts?</p>