Is it possible to specify the name of the Index property to use for lists in a fluent nhibernate con

Posted by Teevus on Stack Overflow See other posts from Stack Overflow or by Teevus
Published on 2010-03-12T07:20:23Z Indexed on 2010/03/12 7:27 UTC
Read the original article Hit count: 167

Filed under:

When mapping a HasMany or HasManyToMany in fluent nhibernate, you can specify the column name to use for the list as a parameter to the AsList() method as follows:

HasMany(c => c.Customers)
    .AsList(c => c.Column("PositionIndex"));

I would prefer to be able to set this using a Fluent NHibernate convention (either a pre-existing one, or a custom one), especially since the default name appears to be "Index" which is a reserved word in MSSQL.

I've tried using a custom convention implementing IHasManyConvention, but the instance parameter does not seem to contain the information about whether its a list, a bag, or a set, and also does not contain the column details for the index column.

public void Apply(IOneToManyCollectionInstance instance)
{

}

Any ideas?

© Stack Overflow or respective owner

Related posts about fluent-nhibernate