Hi,
I have two classes; Area and LanguageArea. I use LanguageArea to handle translated Areas.
Area.cs
string Title,
string Description,
Pictures(set of Picture class),
LanguageAreas(set of LanguageArea class)
LanguageArea.cs
Language(defines which language area is translated in),
Area,
Title (translated title for the Area),
Description (translated description for the area)
For example when a translated area requested from the UI i get the LanguageArea first
public Area GetByLanguageId(long areaId, byte LanguageId)
{
var langArea = db.LanguageArea
.Where(i => i.Area.id == areaId && i.Language.id == LanguageId).FirstOrDefault();
Area newArea = null;
if (langArea != null && langArea.Area != null)
{
newArea = langArea.Area; // I have copied to area to get area with pictures in it
newArea.Title = langArea.Title; // I got the translated Title
newArea.Description = langArea.Description; // I got the translated description
}
return newArea;
}
With the method above i get the the whole area object with the translated Title and Description. But translated title and description saved into ObjectContext. After that when the default language or any other language requested from UI, it still got the translated title and description from ObjectContext, not the data comes from DB.
I have tried MergeOption.OverwriteChanges
. This time everthing was ok but when saving it saved the translated info not the original one which is on the DB.
I have tried Context.Refresh();
but it looks like a temporary solution.
What do you recommend to handle this situation ?
Thanks