1

I've got a web application with an NHibernate Data Access Layer. I have a large number of user preferences that can be stored, these are mainly booleans for example registering that a dialog has been dismissed and should not be showed again.

The problem is that with NHibernate I need to add to my database schema, and add a property to the persistent class every time a new dialog is added to register if it has been dismissed or not.

There must be an easier way. What is it?

reach4thelasers
  • 26,181
  • 22
  • 92
  • 123
  • 1
    Um... Yeah buddy!... Hence me coming on here and asking a question trying to establish a better way to do things! Have you got anything constructive to contribute, or is "bleh...yuck" all you can offer? – reach4thelasers Dec 29 '09 at 05:01

2 Answers2

2

You could use a settings table to store the preferences and add a value for every dialog:

Table Settings Id, UserId, DialogName, Value

1, 1, FirstDialog, True

2, 1, SecondDialog, False

3, 2, FirstDialog, False

4, 2, SecondDialog, False

Marijn Deé
  • 886
  • 2
  • 13
  • 21
1

Another option is to read this post by Ayende, basically allowing for dynamic fields

A common theme in many application is the need to support custom / dynamic fields. In other words, the system admin may decide that the Customer needs to have a few additional fields that aren’t part of the mainline development.

Also read Ayende's last comment

  • You can put a collection in a dynamic property.
  • You can edit the configuration programatically

Edit For some reason I have just realised that I have answered this question that is over one year old! Got no idea how I got here! Answer is still a good one though

Rippo
  • 22,117
  • 14
  • 78
  • 117