title: Using DetachedCriteria to return generic list of non-AR type
body: <p>I'm fiddling with my repository class and attempted to execute a query with a detached criteria. However, it doesn't seem to like me setting the result transformer to a non AR-type.</p>
  
  <pre><code>public class IncidentRepository
  {
      public static IList&lt;AuditReport&gt; GetAllIncidentsToAudit()
      {
          DetachedCriteria dc = DetachedCriteria.For&lt;Incident&gt;("i")
              .SetProjection(
                  Projections.ProjectionList()
                      .Add(Projections.Property("i.Id"), "IncidentId")
                      .Add(Projections.Property("l.Id"), "LocationId")
              )
              .CreateCriteria("Locations", "l")
                  .Add(Expression.Eq("l.PrimaryLocationFlag", "T"))
              .SetResultTransformer(Transformers.AliasToBean&lt;AuditReport&gt;());
  
          return ActiveRecordMediator&lt;AuditReport&gt;.FindAll(dc);
      }
  }
  
  public class AuditReport
  {
      public int IncidentId { get; set; }
      public int LocationId { get; set; }
  }
  </code></pre>
  
  <p>The error I get when executing this query is:</p>
  
  <pre><code>You have accessed an ActiveRecord class that wasn't properly initialized. There are two possible explanations: that the call to ActiveRecordStarter.Initialize() didn't include castle.AuditReport class, or that castle.AuditReport class is not decorated with the [ActiveRecord] attribute.
  </code></pre>
  
  <p>I understand the error but how can I return a strongly typed list of a non-AR type? I've looked at what NHibernate.Transform offers but nothing stands out.</p>
  
  <p>Also, is doing this bad practice?</p>
  
  <p>Edit: I managed to solve it by gaining access to the underlying database session and executing my criteria from there.</p>
  
  <pre><code> ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().
          CreateSession(typeof(ActiveRecordBase));
      ICriteria criteria = sess.CreateCriteria&lt;Incident&gt;("i")
          .SetProjection(
              Projections.ProjectionList()
                  .Add(Projections.Property("i.Id"), "IncidentId")
                  .Add(Projections.Property("l.Id"), "LocationId")
          )
          .CreateCriteria("Locations", "l")
              .Add(Expression.Eq("l.PrimaryLocationFlag", "T"))
          .SetResultTransformer(Transformers.AliasToBean&lt;AuditReport&gt;());
  
      return criteria.List&lt;AuditReport&gt;();
  </code></pre>
  
  <p>Now I'm wondering, is there another of achieving this without manually creating a new session?</p>