views:

112

answers:

2

I need to store localized entities in a database (for instance a Product, which has a Name, which is different in English and Danish). There are several well-known ways to do this, for instance having some sort of a resource table containing the values of the localized columns.

However, this does not seem to be very easy to fit into an ORM, when I want to retrieve an instance of the Product class in the English language and expect the value of the Name property to be English.

I don't want to reinvent the wheel, and I think this is a problem that must be very common. Does any ORM support entity localization out-of-the box ?

Since I am on the Microsoft stack, and obvious choice for an ORM would be Entity Framework 4. Are there any features in EF4 to support this ?

A: 

Maybe you have to look further, I would use NHibernate, and an interceptor to catch the load of an entity and do the localization of the entity, based on the current culture of the application and some way of store the localized strings.

Some resources:

http://elegantcode.com/2008/05/15/implementing-nhibernate-interceptors/

http://knol.google.com/k/fabio-maulo/nhibernate-chapter-11/1nr4enxv3dpeq/14#

Argons
It's just a part of the problem.
Alex Yakunin
+4  A: 

AFAIK EF4 does not provide anything like this.

Dmitri Maximov has written a good series of post covering implementation of localization for DataObjects.Net, the info there may be helpful for you even if you're using (or going to use) any other framework:

Alex Yakunin