"Lose your memory in a thousand places, disappearing in a sea of faces, always alone, I live the only way I know" (John Miles)

Map char values to enums using NHibernate Custom Types - Comments

3 Comments
Hey, that's an awesome feature, I guess NHibernate has some very powerful mapping capabilities. Just wondering, what if you used an external lookup table for those statuses, could you still map them as enums? I'm planning on using a DDD (Domain Driven Design) approach for my next project and will probably implement statuses as enums throughout.
Posted by Dominic Pettifer on Sunday, July 05, 2009
I guess you can also map them to an enumerator using this technique, but you'll be missing some things. You're using mostly a table because your statuses are likely going to change (add new ones, remove old ones). If you'll be using Enums, you will need to recompile and deploy again because the Enum will be in your code. I have currently a simular situation in my project where we have a table with statuses linked to another table. I just implemented it with a normal one-to-one mapping between 2 objects (for now). Let me know if you find a better solution ;)
Posted by Ronald on Tuesday, July 07, 2009
This is poopin awesome!! I took it and genericized it to work with any enum (eg, new EnumCharType(Type enumType, char defaultVal). Email me for the code.
Posted by Jeff Hagen on Sunday, November 08, 2009

Name:        
E-mail:          
Homepage:  

Comment (no HTML):