S.M.Amin
S.M.Amin

Reputation: 509

Fluent NHibernate - How map an IList<Enum> as list of strings

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.

Upvotes: 1

Views: 581

Answers (1)

Firo
Firo

Reputation: 30813

use the override to specify the NHibernate.Type explicitly

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

Upvotes: 2

Related Questions