title: NPoco One-To-Many and Many-To-Many
body: <p>I'm having difficulty mapping one-to-many and many-to-many SQL relationships to Lists in my pocos. I've tried all manner of Fetch and Query as well as attributes and I'm not getting the pocos mapped properly. Here's a simplified version of the classes and SQL:</p>
  
  <p>Pocos:</p>
  
  <pre><code>[NPoco.TableName("Product")]
  [NPoco.PrimaryKey("ProductId")]
  public class Product
  {
      public int ProductId { get; set; }
      public List&lt;Category&gt; Categories { get; set; }
      public string Name { get; set; }
      public List&lt;ProductVariant&gt; ProductVariants { get; set; }
  }
  
  [NPoco.TableName("Category")]
  [NPoco.PrimaryKey("CategoryId")]
  public class Category : ModifiedDomainObject
  {
      public int CategoryId { get; set; }
      public string Name { get; set; }
  }
  
  [NPoco.TableName("ProductVariant")]
  [NPoco.PrimaryKey("ProductVariantId")]
  public class ProductVariant : ModifiedDomainObject
  {
      public int ProductVariantId { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>SQL query:</p>
  
  <pre><code>SELECT[Product].[ProductId], 
  [Product].[PublicId], 
  [Product].[Name], 
  [Category].[CategoryId],
  [Category].[Name],
  [ProductVariant]
  [ProductVariantId],
  [ProductVariant].[ProductId],
  [ProductVariant].[Name],
  FROM[Product]
  JOIN[ProductCategory] on[ProductCategory].[ProductId] = [ProductCategory].[ProductId]
  JOIN[Category] ON[ProductCategory].[CategoryId] = [Category].[CategoryId]
  LEFT OUTER JOIN[ProductVariant] ON[Product].[ProductId] = [ProductVariant].[ProductId]
  WHERE[Product].[ProductId] = 1 
  ORDER BY[Product].[ProductId], 
  [Category].[CategoryId], 
  [ProductVariant].[ProductVariantId];
  </code></pre>
  
  <p>So, Product->ProductVariant is a one-to-many, with the ProductVariant table carrying ProductId; and the Product->Category is a many-to-many with a xref table [ProductCategory] carrying ProductId and CategoryId. The closest I've gotten is the ProductVariant list populated with the correct number of objects, but the values are being mapped from the Product data.</p>
  
  <p>I've worked with PetaPoco for a long time and am now attempting to "upgrade" to NPoco V3. Where with PetaPoco I would use Relators to do the mapping; with NPoco the examples online don't work for me.</p>