We are trying to design a site that will support multilingual data and
we use asp.net and nhibernate for O/R mapping. After some googling we
decided that for us its best to create the entity classes containing
all fields we need for supporting the default (english) language and
for each multilingual class we would create a new class containing
only the multilingual fields plus the id of the main (english) class
and the language Id. For example a simple "product" class we could
have the fields :
product
---------------------------------------
int ID
string DescriptionInEnglish
string FullDescriptionInEnglish
decimal price
and a second class "product_Lang" containing
product_Lang
------------------------------
int Product_ID
int Language_ID
string Description
string FullDescription
then for being able to load a product in any language we could add a
product_Lang property called lang on the products and for easy binding
we could have two read only properties like that :
string DescriptionToBind
{
get
{
if (lang != null)
return this.lang.Description;
else
return this.DescriptionInEnglish;
}
}
string FullDescriptionToBind
{
get
{
if (lang != null)
return this.lang.FullDescription;
else
return this.FullDescriptionInEnglish;
}
}
for loading some products we can use some methods on the
ProductRpository like that :
Product GetProductByID(int ID);
Product GetProductbyID_ML(int ID, int Language_ID);
and for loading some collections
IList<Product> GetAllProducts(int ID);
IList<Product> GetAllProducts_ML(int ID, Language_ID);
The problem is how to map the Lang property inside the product class
in nhibernate. It may be easy but I cannot figure out. Its not one-to-
one because in english lang is optional. I thought about one-to-many
so i load a list of all but i think its not fair to load all languages
because i need only one.
Any help ? or any other suggestions will still give fair performance ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---