Thanks a lot for the reply. I'll give it a try.
Should the code like this still work correctly with NH: address.Country = Countries.Austalia Session.Update(); Session.Flush(); address.Country = Countries.Germany Session.Update(); Session.Flush(); Assert.AreSame(Countries.Germany, address.Country) Cheers. 2009/7/30 Nexus <[email protected]> > > Hey > > At first set your id to assigned, use guid or something like that. > > Second overload your Equals, gethashcode, (use id as equalifier) , > also overload operators > > Then create a static class countries > > public static class Countries > { > > public readonly static Country Australia = new Country > ("EF989B65-1714-4e51-BAC2-D1766CA15A2C", "Australia"); > > // Optional > > public static IEnumerable<Country> All > { > get > { > yield return Australia; > // ... > } > } > > } > > > Kind Regards , remember assigned id's cannot be used with > saveorupdate, only save !!! > > > > > On 30 jul, 07:20, Dmitiry Nagirnyak <[email protected]> wrote: > > Anybody please? > > > > 2009/7/29 Dmitiry Nagirnyak <[email protected]> > > > > > > > > > Hi, > > > > > I would like to use code like this for my lookup classes: > > > > > if (address.Country == Countries.Australia) > > > { > > > // Do something > > > } > > > > > Here the Countries class is defined like this: > > > public class Countries > > > { > > > public Country Austrlia > > > { > > > get > > > { > > > return ObtainLokupFromDB("Australia"); > > > // OR > > > return new Country > > > { > > > Id = 14, > > > Code = "Australia", > > > Description = "Australia" > > > } > > > } > > > } > > > > > But I am not sure hot to implement this. > > > On one hand I don't want to go to the database as I know all the values > > > even at compile time. > > > But if I'll create a Country instance it won't allow me to use "==" > > > operator to compare teh values (so I need to override Equals and > > > GetHashCode). > > > > > What are your suggestions on this? > > > > > Cheers, > > > Dmitriy.- Tekst uit oorspronkelijk bericht niet weergeven - > > > > - Tekst uit oorspronkelijk bericht weergeven - > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
