title: Converting IPublishedContent to Dtos and performance
body: <p>I'm wondering if anyone else has experienced this before?</p>
  
  <p>I should start by saying I'm not using ModelsBuilder for this project. I was having too many problems with it so abandoned that route.</p>
  
  <p>I am however converting IPublishedContent items into Dtos within my app, using a converter class that basically maps the values. The problem I'm finding is that it's causing a massive slowdown in my code execution, especially in comparision to just getting the raw IPublishedContent collection.</p>
  
  <p>To give you an example, I have a 'Job' document type. Jobs can be assigned to workers. In one of my services I need to get a collection of all jobs assigned to a worker:</p>
  
  <pre><code>public IEnumerable&lt;IPublishedContent&gt; GetJobsForWorker(int workerId)
  {
      var jobs = Umbraco.TypedContent(1234);
  
      return jobs.Descendants("job").Where(j =&gt; j.GetPropertyValue&lt;int&gt;("assignedWorker") == workerId).ToList();
  } 
  </code></pre>
  
  <p>This function returns a collection of IPublishContent, which returns lightning fast, as I'd expect.</p>
  
  <p>However if I try and convert the results to my job Dto class, it goes from taking 0 seconds, to around 7.. and that's just returning a collection of ~7 from ~20 or so records:</p>
  
  <pre><code>public IEnumerable&lt;Job&gt; GetJobsCompletedByWorker(int workerId)
  {
      var jobs = Umbraco.TypedContent(1234);
  
      return jobs.Descendants("job").Where(j =&gt; j.GetPropertyValue&lt;int&gt;("assignedWorker") == workerId).Select(node =&gt; _jobConverter.ConvertToModel(_umbracoHelper, node)).ToList();
  }
  </code></pre>
  
  <p>Now I'm not doing any complex processing in this converter, it's just mapping the values as such:</p>
  
  <pre><code>public class JobConverter
  {
      public Job ConvertToModel(UmbracoHelper umbracoHelper, IPublishedContent node)
      {
          if (node != null)
          {
              var job = new Job
              {
                  Id = node.Id,
                  Property1 = node.GetPropertyValue&lt;string&gt;("property1"),
                  Property2 = node.GetPropertyValue&lt;string&gt;("property2")
                  ... more properties
              };
  
              return job;
         }
  
         return null;
     }
  }
  </code></pre>
  
  <p>I'm not really sure what best practice is here? Is there something I'm missing that's causing this slowdown? I only ask because I've used ModelsBuilder before which essentially does the same thing ie. map umbraco fields to properties, and yet there's nowhere near the same delay.</p>
  
  <p>Ultimately I could just use IPublishedContent, but it makes for messy code and it's far more difficult to understand.</p>
  
  <p>I just wonder if anyone's been in this situation before and how they handled it?</p>
  
  <p>Thanks</p>