If the dynamic setup changes very rarely, dynamic-component works great. Create a new configuration and a new session factory, update the schema and replace the current session factory. Of course a bit of careful coding is recommended, but the end result can be really nice and efficient. In many ways superior to a standard EAV model.
I don't think it could be accomplished using ByCode mapping (yet), since Property() hard wires things using lambdas, but I guess it would work to manipulate the actual mapping meta data, just before the configuration is created. /G 2012/3/14 Adam Bar <[email protected]> > DynamicComponent is generally for the cases when you know the > attributes upfront and the only "dynamic" part is that you don't have > it as a properties in your object model, but in a IDictionary instead. > > If you're looking for truly dynamic key-value store, you probably want > to use Map: > http://ayende.com/blog/4045/nhibernate-mapping-map > > and mapping-by-code: > http://notherdev.blogspot.com/2012/02/mapping-by-code-map.html > > Regards, > Adam > > On 14 Mar, 10:04, Exodus <[email protected]> wrote: > > Hi, > > > > I have this code: > > > > mapper.Class<Test>(ca => > > { > > ca.Component(x => x.DynamicAttributes, new > > { > > SomeStringAttribute1 = "" > > }, dc => > > { > > dc.Property(arg => > > arg.SomeStringAttribute1); > > }); > > } > > ); > > > > Is there a way to map a variable number of "SomeStringAttributes" where I > > know the number first at runtime. I know I could generate XML for the > > mapping and do it that way, but is it a way to do this when mapping by > > code? :) > > > > Regards, > > Peter > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
