I am trying to setup a many-to-many mapping in Fluent Nhibernate that has a where clause attached to the child table.
This is basically how it should work:
HasManyToMany(p => p.Images)
.Table("ProductImages")
.ParentKeyColumn("ProductID")
.ChildKeyColumn("ImageID")
.Where("ImageTypeID = 2");
The ImageTypeID column is in the Images table, but NHibernate is assuming it is part of the ProductImages table. Any idea how I can specify this?
Thanks!
You can. Use .ChildWhere in your Fluent NHibernate mapping:
HasManyToMany(p => p.Images)
.Table("ProductImages")
.ParentKeyColumn("ProductID")
.ChildKeyColumn("ImageID")
.ChildWhere("ImageTypeID = 2");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With