abombss wrote:
Can you post a brief an example of how current project does this. How are you accessing the new data column through the existing code? Is it something like Object.GetCustomField("MyField") ?
That is as good an analagous description as any.
The current project uses recordsets (MFC, CRecordset-derived) for the CRUD code, and the tables that support custom fields have a dynamic component (basically a linked list of column/value pairs) where the columns are provided after the database connection is established and then the recordset will bind and load the correponding values.
So, it's basically just rs.GetFieldValue("MyField")
I have done some more research since my original post, and the <dynamic-component> tag does in fact work well in my testing (but I have provided the XML statically in the file at this point before I wade into doing changes at runtime).
E.g. using your field name:
XML:
<dynamic-component
name="CustomFields"
access="property">
<property
name="MyField"
column="MyField"
type="System.String">
</property>
</dynamic-component>
C# code in class:
private IDictionary customFieldDictionary;
public virtual IDictionary CustomFields
{
get { return customFieldDictionary; }
set { customFieldDictionary = value;
}
}
---------------
Then you would just use the CustomFields IDictionary interface to read/write the fields. Unfortunately, they aren't directly bindable without doing extra work, I'm not at all surprised by that.
It took some experimenting to see what was actually happening under the covers. NHibernate instantiates a Hashtable to hold the values, but only if it encounters a non-null value. It actually calls the "set" property to populate your IDictionary member.
So, I need to figure out how to populate that property list after I load a configuration but before I instantiate the session factory, and I can make this work!