问题
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>>())
来源:https://stackoverflow.com/questions/19597088/fluent-nhibernate-how-map-an-ilistenum-as-list-of-strings