Hi,
I have a situation in which I have to add a type of an object to nhibernate configuration at run time. We would know the class name and data members of the class only at run time. We want to create a separate data table on the database server for each of these dynamic types. My initial idea was to use the ".NET TypeBuilder" to create the new type and use the "NHibernate.Configuration.AddClass" to register the new type and then provide the mapping for the new type using "NHibernate.Configuration.AddXMLString" . After this we expect that this new dynamic type can now we used like any other class type we use with Nhibernate.
But I am running into issues / exceptions, When using the "NHibernate.Configuration.AddClass", getting an exception as "The invoked member is not supported in a dynamic assembly." I was able to debug the NHibernate code and it is looking for the Mapping file for the new type we added and raising this exception. So I tried the other way around adding the mapping file first, the call "NHibernate.Configuration.AddXMLString" when called first fails with an exception "Could not compile mapping document".
My suspicion is that these method of the "NHibernate.Configuration.AddClass/AddXMLString" are not intended for registering the new dynamic types. Can someone suggest me an approach for our problem
Thanks in advance
|