|
Hi all,
I'm trying model the following problem so it works in NHibernate; I think there's a problem with my model because I can't figure out how to make it play nice with the ORM. Any help is appreciated...
Background
I'm basically writing a document templating system. Where the document template is configurable using a bunch of input widgets. The widget behaviors and data types are configurable, too. So you can have a document template that has 1...n widgets of different types.
You might have a widget that accepts text input from the end-user and you want to change its Label for a certain document.
On the other side, I have end-users filling out the documents and I need to capture their input. When they open the document, any input they did has to be restored.
Current State
So... I have Types that can be configured. The configurations are stored in a database. At runtime, the Types can have their states changed by the user.
My model has a Configuration class and an Item. A single type can be configured for different contexts. But parts of the type will be changed and stored/restored for individual users. For example...
class ItemA
{
string Label { get; } // persisted in configuration
string Input { get; set; } // persisted by user
}
In one configuration context, Label = "Enter Code"; in another, it might be "First Name".
Requirements
Input must be saved separately because it can be different for multiple users in the same configuration context. And it must be restored from the database once it has been set by a user.
When I save ItemA, I only want to save the value of Input. Conversely, when I load ItemA for a given user, I want to load it with the common Label but with the changed value of Input (if any).
I want to set and save the Label property separately. So far, I've determined that I can use Configuration.Label for that and just map from the Configuration object to the 'real' object, but I'm open to other approaches.
In sum, I'd like some guidance on how to model this so it works in NHibernate and I can take advantage of all its goodness.
Cheers & Thanks!,
Komptaur
|