Scratch that... Enums are mapped as ints by default. I should really proof read my responses this early in the morning.
On Tue, Aug 3, 2010 at 5:15 AM, Jason Dentler <[email protected]>wrote: > By default, Enums are mapped as strings. > > NH has two other custom enum types: > NHibernate.Type.EnumStringType<T> > NHibernate.Type.EnumCharType<T> > > I assume the latter does what you want. > > > On Tue, Aug 3, 2010 at 4:44 AM, Frans Bouma <[email protected]> wrote: > >> > Or better: >> > >> > public class Something >> > { >> > protected virtual int myIntValue { get; set; } >> > public MyEnumeration MyEnumeratedValue >> > { >> > get >> > { >> > return((MyEnumeration) this.myIntValue); >> > } >> > set >> > { >> > this.myIntValue = value; >> > } >> > } >> > } >> >> that would be built-in natively by nhibernate already. >> Topicstarter >> wanted to convert to char: 'A', 'I' etc. not to int :) >> >> FB >> >> > >> > >> > On Aug 3, 8:14 am, "Frans Bouma" <[email protected]> wrote: >> > > Implement IUserType for this conversion between 'Enum' (model side) >> > > and Char (db side) and vice versa, then assign the IUserType >> > > implementation to the field in question by specifying it in the >> mapping. >> > > >> > > FB >> > > >> > > >> > > >> > > > I've a status field on my table users and i wish to make this field >> > > > with defined data 'A' = active, 'B' = block, 'I' = inative. >> > > > Before I use NHibernate I used an enum in C# and I converted it to >> > > > char before save and to enum after select. >> > > >> > > > Someone have a tip for do it? >> > > > of course hard codes are not so good. >> > > >> > > > Thank you for your help. >> > > >> > > > Rúben Lício Reis >> > > > +55 11 67041245 >> > > >> > > > -- >> > > > You received this message because you are subscribed to the Google >> > > > Groups "nhusers" group. >> > > > To post to this group, send email to [email protected]. >> > > > To unsubscribe from this group, send email to >> > > > [email protected]<nhusers%[email protected]> >> . >> > > > For more options, visit this group at >> > > >http://groups.google.com/group/nhusers?hl=en. >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "nhusers" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]<nhusers%[email protected]> >> . >> > For more options, visit this group at >> > http://groups.google.com/group/nhusers?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<nhusers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
