Hi all, Just wanted to add to this thread that Jimmy Bogard just put up a shiny new followup post on the exact topic of persisting Enumeration classes with NHibernate. It's located here: http://lostechies.com/jimmybogard/2012/05/01/persisting-enumeration-classes-with-nhibernate/
On Tue, May 1, 2012 at 9:54 AM, Oskar Berggren <[email protected]>wrote: > With this pattern PricingStrategy shouldn't be mapped at all since you > should only use the well-known instances available as class variables > from the class itself. You can still have a table for it, which NH > knows nothing about, if you want to use foreign keys in the DB to > control the strategy ids in other tables. > > /Oskar > > > 2012/5/1 Chris B <[email protected]>: > > I knew I was making some kind of bone-headed mistake.... For anyone who > is > > interested, the test I gave before will never pass. > > > > For reference, here is the test: > > > > var fromSession > > = session.Get<PricingStratey>(PricingStrategy.FullStock.Id); > > > Console.WriteLine(object.ReferenceEquals(fromSession, > PricingStrategy.FullStock); > > // prints false > > > > This will always print false because the PricingStrategy class is not > mapped > > as an IUserType, the Product.PricingStrategy *property* is mapped as an > > IUserType. Duh. > > > > Here is an amended test that works. > > > > var fromSession = session.Get<Product>(1); > > > Console.WriteLine(object.ReferenceEquals(fromSession.PricingStrategy, > PricingStrategy.FullStock); > > // prints true > > > > FWIW, I really wish there were a way to say that the PricingStrategy > class > > itself should be mapped with an IUserType instead of having to mark all > > properties as using the IUserType. I think being able to mark specific > > properties is useful in certain cases too, it would just be nice to have > a > > global default. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/nhusers/-/9u24iVBEZewJ. > > > > 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. > > -- > 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. > > -- 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.
