Hi nordside, I'm trying to understand what you're looking to achieve. A NHibernate MAP-type construct usually has a table looking like this:
CREATE TABLE IF NOT EXISTS `setting` ( `CustomerId` int(11) NOT NULL, `SettingKey` varchar(50) NOT NULL, `SettingValue` varchar(500) NOT NULL, PRIMARY KEY (`CustomerId`) ) Should you need more columns, as you would need to in order to have Setting1 and Setting2 as columns, then I'd recommend rather going with a standard NHibenate mapping. i.e. using Fluent NHibernate's Map as you would for a conventional HasMany relationship. What you're looking for is achievable with AsMap semantics. The keys would just need to be stored vertically, not horizontally. Your Setting1 and Setting2 (as text) and the values for these keys will be stored as key-value pairs in the table structure, such as the one pasted above. I'm not sure if it's possible to use an enum as the identifier as the foreign key is typically your referring table, in this case Customer. Perhaps consider instead using a constants class in your code to stored the string values. Example: public class SettingsType { public static readonly string Private = "private"; public static readonly string Public = "public"; } Let me know how that goes. Regards, Dion On Sun, Jun 3, 2012 at 11:47 AM, <fluent-nhibernate@googlegroups.com> wrote: > Today's Topic Summary > > Group: http://groups.google.com/group/fluent-nhibernate/topics > > - Digest for fluent-nhibernate@googlegroups.com - 1 Message in 1 > Topic<#137b1bd9a1128546_group_thread_0>[1 Update] > > Digest for fluent-nhibernate@googlegroups.com - 1 Message in 1 > Topic<http://groups.google.com/group/fluent-nhibernate/t/a3deb6cd4024f1e6> > > nordside <matthias.schi...@googlemail.com> Jun 02 07:29AM -0700 > > Hi Dion, > > thanks for your post, but it doesn't work for me out of the box. > > public Customer() > { > Settings = new Dictionary(); // it is necessary to specify type for > key and value > } > > In this way I specify an enumeration for the key > > public enum SettingType > { > PrivateSetting, > PublicSetting > } > > and a class for the value > public class Setting > { > public virtual string Setting1 { get; set; } > > public virtual int Setting2 { get; set; } > } > > At the end I modify the constructor > > public Customer() > { > Settings = new Dictionary<SettingType, Setting>(); > } > > > Now the question: how to map this? I try out several solutions i found > in groups, blogs etc. > > HasMany<Dictionary<SettingType, Setting>>(x => > x.Settings).AsEntityMap(); > > HasMany(x => x.Settings) > .Component(c => > { > c.Map(x => x.Setting1); > c.Map(x => x.Setting2); > }); > > HasMany<Setting>(x => x.Settings) > .AsEntityMap() > .Not.LazyLoad() > .Inverse() > .Cascade.AllDeleteOrphan(); > > > Have you got an hint to help me? > > Thanks > nordside > > > Am Donnerstag, 31. Mai 2012 18:00:52 UTC+2 schrieb Dion: > > > > You received this message because you are subscribed to the Google Group > fluent-nhibernate. > You can post via email <fluent-nhibernate@googlegroups.com>. > To unsubscribe from this group, > send<fluent-nhibernate+unsubscr...@googlegroups.com>an empty message. > For more options, > visit<http://groups.google.com/group/fluent-nhibernate/topics>this group. > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To post to this group, send email to fluent-nhibernate@googlegroups.com. > To unsubscribe from this group, send email to > fluent-nhibernate+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.