title: how i get this tree view nodes inside a task in C#
body: <p>i have the following method which i get a tree view by root parent in json but it is taking too long, how i change this to inside a task, i tried many things, but always get an exception like InvalidOperationException: There is already an open DataReader associated with this Command that must be closed first.</p>
  
  <pre><code> public JsonResult GetTreeContasContabeis()
      {
          var rootItens = new List&lt;ContaContabil&gt;();
          var allCounts = UnitOfWork.ContasContabeis.All();
  
  
          rootItens = allCounts.Where(x =&gt; x.ContaContabilPai.Id == null).ToList();
  
  
          var retorno = new List&lt;TreeViewRetorno&gt;();
  
          foreach (var item in rootItens)
              retorno.Add(GetItemContaContabil(item));
  
          retorno.OrderBy(p =&gt; p.text);
  
          return Json(retorno);
      }
  
  
   private TreeViewRetorno GetItemContaContabil(ContaContabil contaContabil)
      {
          var item = new TreeViewRetorno();
          item.id = contaContabil.Id;
          item.text = $"{contaContabil.NumeroConta} - {contaContabil.DescricaoConta}";
          item.hasChildren = (contaContabil.ContasFilhas != null &amp;&amp; contaContabil.ContasFilhas.Any());
          item.isTipo = contaContabil.TipoClassificacaoContaContabil;
          item.items = new List&lt;TreeViewRetorno&gt;();
  
          if (item.hasChildren == true)
          {
              foreach (var filha in contaContabil.ContasFilhas)
                  item.items.Add(GetItemContaContabil(filha));
          }
          return item;
      }
  
   public class TreeViewRetorno
      {
          public Guid? id { get; set; }
          public string text { get; set; }
          public bool hasChildren {get;set;}
          public TipoClassificacaoContaContabil isTipo { get; set; }
          public List&lt;TreeViewRetorno&gt; items { get; set; }
      }
  </code></pre>