I have a scenario where I need to localized values of objects in my database.
Let's say you have an application that can create animals, if the user is english the value of the "Name" property of an animal would be entered as "Cat" in the UI whereas it would be entered as "Chat" in french.
The animal culture table would contain 2 records pointing to the same animal in the parent table.
When reading values back, if the value of "Name" does not exist in the user culture the default value (value the object was originally created with) would be used. The following diagrams demonstrate how the data is stored in SQL:
I'm trying to map this schema to an object model using the Entity Framework, I'm a bit confused as to what the best way to approach the problem.
Is EF appropriate for this? Should I used EF4?
This EF model will be used by .NET RIA Services.
Thanks,
Pierre-Yves Troel
What I did in a similar situation is created a view say LocalizedAnimals which is a flat representation of that 2 table structure and created an EF model for that view. So when I need to display say French animal data I would filter those LocalizedAnimals and have nice simple object list as a result.
Something like this:
var localizedAnimals = myContext.LocalizedAnimals.Where(
p => p.CultureName == Thread.CurrentThread.CurrentUICulture.Name
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With