Sean Chambers
Sean Chambers

Reputation: 8680

Map dynamic/generic properties with NHibernate

I have a scenario where I have a propertybag of key/values that would look something like:

Entry 1 : key="Load", value="2", type="int"
Entry 2 : key="DailyStatus", value="0", type="bool"

I am trying to figure out if it's possible with nhibernate to map these values to a single table that I can pull out at a later time into .net simple types.

I am trying to avoid creating classes to contain all of this data as it can be very repetitive and doesn't allow portions of the application to be as flexible as possible. I had considered storing it in XML or JSON, but this data has to be queried against on a pretty regular basis.

Has anyone mapped dictionaries of simple types to a table in nhibernate and pulled the data back out? I suppose mapping to a generic dictionary would work:

IDictionary<string, IDictionary<object, Type>>

I can do it by hand, but if there is a builtin way for nhibernate to accomplish it that would be easier.

Upvotes: 0

Views: 699

Answers (1)

epitka
epitka

Reputation: 17637

How about you create a class "Triplet" with attriutes id, key, value, type and then map it to a table called whatever you want?

Upvotes: 1

Related Questions