Fluent NHibernate - displaying a CultureInfo object?

I have a class like:

public class User { public CultureInfo Culture {get;set;} } 

I have a display class as follows:

 public class UserMap : ClassMap<User> { public UserMap() { ?? } } 

I would like to store this information about user culture in and out of the database as a culture string (for example, "en-US"). I am new when it comes to NHibernate and Fluent NHibernate. How to tell the cartographer to use the culture string when saving and create a cultural object when retrieving?

+4
source share
1 answer

Not as simple as telling NHibernate to save the class as a string, you have to provide a mapping that works and vice versa. To do this, run IUserType as described in this article .

You can then map it as Map(x => x.Culture).CustomType<CultureType>() if your IUserType implementation is called CultureType .

+5
source

All Articles