Fluent NHibernate - How map an IList as list

2019-08-05 06:40发布

问题:

I have a class with IList<Role> roles as a property which is mapped by the following code:

 map.HasMany(u=>u.roles).Element("role").Cascade.All()

but this maps roles to a column of int but I want it to be mapped to a column of string.

回答1:

use the override to specify the NHibernate.Type explicitly

.Element("role", e => e.Type<NHibernate.Type.EnumStringType<Role>>())