Im using the AutoPersistenceModel in Fluent NHIbernate to map all my entities and that all works fine :D
However, several of my objects have
public virtual IList<Comment> Comments { get; set; }
In the database there is a single comments table, and each entity with the above code, has its own link table to comments.
At the moment what im doing is:
public class ContractMappingOverride : IAutoMappingOverride<Contract>
{
public void Override(AutoMap<Contract> mapping)
{
mapping.HasManyToMany(x => x.Comments)
.WithTableName("Comment_Contract");
for every entity.
Is there some way i can set a convention where by all mappings to IList<Comment> are wired up automatically as manytomany with the above table name convention?
Thanks
Andrew
I know it's not what you want to hear, but the answer is no.
In the current design of Fluent NHibernate, there isn't a way to apply conventions to collections while having knowledge of the types they're being used in, you can apply something to all collections just not depending on their contained type. This is a flaw in our design and I aim to correct this, but it is quite a large change so it won't be happening overnight.
I'd recommend you check in with our mailing list, we usually post updates there.
Sorry I can't be more helpful.
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