title: FindAll best practices in nhibernate
body: <p>I have on top entity with many child entities.</p>
  
  <p>Now, I want implement FindAll() method where I'm using this pattern with querying all my top entities to List. That's fine but I then get all my child objects with it, Alert: Select N+1 in nhib. profiler. </p>
  
  <p>After I get all my objects I send them to FromMyDomainModel method to extract values to ViewModel I need. </p>
  
  <pre><code>   using (ITransaction transaction = session.BeginTransaction())
     {
         List&lt;Property&gt; data =
                     session.Query&lt;Property&gt;()//I don't need fetch
                     .ToList();
          transaction.Commit();
          return EntityViewModel.FromDomainModel(data);
      }
  </code></pre>
  
  <p>Maybe there is better pattern so please feel free to post.</p>
  
  <p><strong>update: mapping code</strong>
  from mapping you can figure it my entity code</p>
  
  <pre><code>   public PropertyMap()
          {
              Table("Property");
              Id(x =&gt; x.Id).GeneratedBy.Identity();
              Map(x =&gt; x.Version);
              Map(x =&gt; x.Created);
              Map(x =&gt; x.Updated);
              Map(x =&gt; x.Views);
             ....
              Map(x =&gt; x.Price);            
              HasMany(x =&gt; x.Photos).KeyColumn("PropertyId").Cascade.All();
          }
  
   public PhotoMap()
          {
              Table("Photo");
              Id(x =&gt; x.Id).GeneratedBy.Identity();
              Map(x =&gt; x.ImageData).CustomSqlType("VARBINARY(MAX)").Length(160000).Not.Nullable();
              Map(x =&gt; x.ImageMimeType).Not.Nullable();
              References(x =&gt; x.Property).Column("PropertyId");
  
          }
  </code></pre>