Fluent NHibernate is a lot for many conventions for type

I use AutoPersistenceModel in Fluent NHIbernate to display all my objects and that everything works fine: D

However, some of my objects have

public virtual IList<Comment> Comments { get; set; } 

There is one comment table in the database, and each object with the above code has its own comment link table.

At the moment, what I'm doing:

 public class ContractMappingOverride : IAutoMappingOverride<Contract> { public void Override(AutoMap<Contract> mapping) { mapping.HasManyToMany(x => x.Comments) .WithTableName("Comment_Contract"); 

for every entity.

Is there a way I can establish an agreement where all mappings with IList <Comment> are automatically connected as many of them have the above table name convention?

thanks

Andrew

+7
fluent-nhibernate
source share
2 answers

I know that this is not what you want to hear, but the answer is no.

In the current Fluent NHibernate design, there is no way to apply conventions to collections if you have knowledge of the types in which they are used, you can apply something to all collections, regardless of their contents. This is a flaw in our design, and I'm trying to fix it, but it's a pretty big change, so it won’t happen overnight.

I would recommend you register on our mailing list , we usually post updates there.

Sorry, I could not be more helpful.

+5
source share

Some time has passed since I worked with Fluent NHibernate, and now I’m just returning to the swing (wow, there have not been many changes since the beginning of year 09), and I think that the answer to your question is yes now, you can do this using OverideAll features.

Check out Overrides on the FNH Wiki.

0
source share

All Articles