I have a dictionary that I compile using Fluent NHibernate. The dictionary has a complex key type CultureInfo . My database cannot save this type, so I want to use its string representation.
In mappings other than dictionary mappings, I can successfully map CultureInfo -properties using a user type convention. Now I am wondering how to do this for wild mappings.
Here's the object containing the dictionary:
public class MultilingualPhrase : Entity { private IDictionary<CultureInfo, string> languageValues; public virtual IDictionary<CultureInfo, string> LanguageValues { get { return languageValues; } } }
And here is the redefinition of automatic display for the object:
public void Override(AutoMapping<MultilingualPhrase> mapping) { mapping .HasMany(n => n.LanguageValues) .Access.ReadOnlyPropertyThroughCamelCaseField() .AsMap<string>("CultureName") .Element("Phrase") .Table("MultilingualPhraseValues"); }
This mapping (obviously) causes the following error:
Failed to convert parameter value from CultureInfo to string.
I know that NHibernate has a type of custom type for CultureInfo (I use it for mapping properties), but how to specify it in display override?
source share