Hello,
I am a new nHibernate user and am trying to map a common pattern that I have in nHibernate and am wondering if anyone could provide any guidance. Essentially I have three tables:
Code:
CREATE Table Setting
AS
SettingId int not null,
DefaultValue nvarchar(max),
SettingKey nvarchar(50)
CREATE TABLE UserSetting
AS
UserId int not null,
SettingId int not null,
SettingValue nvarchar(max)
CREATE TABLE User
AS
UserId int not null,
...other columns excluded
What I would like is for this to map to an IDictionary<string,Setting> on User.
Setting is defined as
Code:
public class Setting
{
property string Value{get;set;}
property SettingDefinition{get;set;}
}
public class SettingDefinition
{
property string Key{get;set;}
property string DefaultValue{get;set;}
}
I've also tried to do a simillar mapping and have just a Dictionary<string,string> on the user (And I would ignore the default value for now).
The only way I've been able to do this is by creating a view and using that as the table in the mapping file. But this then requires me to write some triggers on the views to gets the data access to work right and to me seems counter productive.
Can anyone point me to some resources or have any suggestions or ideas. I'd appreciate it.
Thanks,
Josh