I am trying to create an application-wide Settings table:
Settings
Name | Value
--------------------------
Config1 | "A text string"
Config2 | "true"
Config3 | "100"
Name and value are both varchar type. I’m trying to map this to a Dictionary object in some way in a Settings class:
public class ApplicationSettings
{
protected virtual void IDictionary Settings { get; set; }
public string Config1 {
get { return Settings["Config1"]; }
set { Settings["Config1"] = value; }
}
// etc
}
Note: This prior question is the closest I can find to what I’m trying to do, but it doesn’t show the NHibernate mapping used.
I know that NHibernate has a <map/> tag, so that I can attach just such a dictionary to another mapped object (for instance a UserSettings dictionary mapped to a User class). But in my case, these are global settings, so there is no parent object to attach to.
Can anyone explain what the mapping would look like for this situation, or if the <map/> tag can’t be used, some other way (criteria query, named SQL query) to load and save from this type of table?
1 Answer