Reputation: 241
I want to add localization support to my domain object. I have the following:
class Person
{
int Id;
City city;
}
class City
{
int Id;
string Name;
}
All cities are saved in a lookup db table Cities
. I would like to have:
Person p = PeopleService.GetPersonById(1);
//Assert p.City.Name == 'London' if culture == 'en-us'
I dont like doing
string City::Name { get { return ILocalizationProvider.Get(typeof(City), Id); }
I came by this article:
http://ayende.com/Blog/archive/2006/12/26/LocalizingNHibernateContextualParameters.aspx
Yet I dont know whether its supported in NH 2.1 or not.
How can I instruct NH to cache all cities in 2nd-level cache to avoid joins each time for the same locale?
Is there an easy and neat way to treat database lookup tables and localization in NHibernate ?
Upvotes: 5
Views: 844
Reputation: 323
In the article it says "Please note that this is no longer supported behavior in NHibernate 2.1 and up. It was a hack to begin with, and it isn't guaranteed to continue working."
So this will not work in your scenario. I would recommend this: http://nhforge.org/wikis/howtonh/localization-techniques.aspx
Upvotes: 3