Hi, I'm sorry for the delay but I'm on vacations and no internet access is available.
I'm trying to represent a single location in different languages. I tried the following workaround.
I have one class with the language independent attibutes of a Location and one class with language dependent attributes. In the first class I have a property that returns the second class, according to a lang argument. Here's the implementation
Public
Class LocationPrivate
_Details As Dictionary(Of String, LocationDetails) .
.
.
Public ReadOnly Property Details(Optional ByVal locale As String = "") As LocationDetails
Get
Dim mLocale As String
If locale = "" Then
mLocale = MyLanguage.CurrentLanguage
Else
mLocale = locale
End If
Dim dets As LocationDetails
If Me._Details.ContainsKey(mLocale) Then
dets = Me._Details.Item(mLocale)
Else
If LocationDetails.Exists(Me._Id, mLocale) Then
dets = LocationDetails.GetLocationDetails(Me._Id, mLocale)
Else
dets = LocationDetails.NewLocationDetails
dets.LocationId = Me._Id
dets.Locale = mLocale
End If
Me._Details.Add(mLocale, dets)
End If
Return dets
End Get
End Property
.
.
.
Public
Overrides Function Save() As Location While i.MoveNext
i.Current.Value.LocationId = Me._Id
i.Current.Value.Save()
End While
Return Saved
End Function
.
.
.
End
ClassIn the Save method first I save the Location object, because in case of a new Location a foreign key is required by the LocationDetails class and then I save any LocationDetails object in the _Details dictionary. Both Location and LocationDetails classes inherit from BusinessBase.
What do you think?
Copyright (c) Marimer LLC