title: C# Fluent NHibernate queryover how to query records from Link table in many to many relation
body: <p>I am new to Fluent NHibernate. </p>
  
  <p>I have the following mappings for many to many relation. </p>
  
  <p>How to write a query using queryover so that bring back records if the product doesn't exist in product table but available in ProductLink table? For some reason the data is not proper as it is legacy system. So doesnt want to ignore records which is not Product table.</p>
  
  <p>Can anyone please help me how to achieve this?</p>
  
  <pre><code>Product productAlias = null;
  Asset assetAlias = null;
  
  var query = Session.QueryOver(() =&gt; assetAlias);
  
  //Condn1: must be linked to a Product number
  query.Inner.JoinAlias(() =&gt; assetAlias.Products, () =&gt; productAlias);           
  
  var result = query
                  .Skip(pageIndex * pageSize)
                  .Take(pageSize)
                  .Future&lt;Asset&gt;();   
  </code></pre>
  
  <p>Asset</p>
  
  <pre><code>public AssetMap()
  {
      Table("ASSET_INFO");
  
      Id(x =&gt; x.Id).GeneratedBy.Assigned().Column("MAT_ID");
  
      Map(x =&gt; x.Title);
  
      HasManyToMany(x =&gt; x.Products)
          .Table("PROD_LINK")
          .AsBag()
          .ParentKeyColumn("MAT_ID")
          .ChildKeyColumn("PROD_NO")
          .Cascade.All()
          .LazyLoad();
  }
  </code></pre>
  
  <p>Product</p>
  
  <pre><code>public ProductMap()
  {
      Table("PROD_INFO");
  
      Id(x =&gt; x.Id).GeneratedBy.Assigned().Column("PROD_NO");
  
      Map(x =&gt; x.Name).Column("PROD_NM");
  
      HasManyToMany(x =&gt; x.Assets)
          .Table("PROD_LINK")
          .ParentKeyColumn("PROD_NO")
          .ChildKeyColumn("MAT_ID")
          .Inverse()
          .LazyLoad();
  }
  </code></pre>
  
  <p>ProductLink</p>
  
  <pre><code>public class ProductLinkMatMap : ClassMap&lt;ProductLinkMat&gt;
  {
      public ProductLinkMatMap()
      {
          Table("PROD_LINK");
  
          CompositeId().KeyReference(x =&gt; x.Asset, "MAT_ID")
                       .KeyReference(x =&gt; x.Product, "PROD_NO");
      }
  }   
  </code></pre>