Fluent nHibernate - How to map a non-key column on a junction table?

Posted by The Matt on Stack Overflow See other posts from Stack Overflow or by The Matt
Published on 2010-06-09T04:05:41Z Indexed on 2010/06/09 15:52 UTC
Read the original article Hit count: 204

Taking an example that is provided on the Fluent nHibernate website, I need to extend it slightly:

alt text

I need to add a 'Quantity' column to the StoreProduct table. How would I map this using nHibernate?

An example mapping is provided for the given scenario above, but I'm not sure how I would get the Quantity column to map to a property on the Product class:

public class StoreMap : ClassMap<Store>
{
  public StoreMap()
  {
    Id(x => x.Id);
    Map(x => x.Name);
    HasMany(x => x.Employee)
      .Inverse()
      .Cascade.All();
    HasManyToMany(x => x.Products)
     .Cascade.All()
     .Table("StoreProduct");
  }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about database