Dynamic model and nhbiernate

Topics: Troubleshooting, Writing modules
May 23, 2013 at 10:34 AM
Edited May 23, 2013 at 10:36 AM
I want to build some type at the runtime, and then use it to retreive data from DB using NHibernate. I've create the type with emit (used code from here) and set NHibernate configuration:
var sessionFactory = this.sessionFactoryHolder.GetConfiguration().AddAssembly(runtimeType.Assembly).BuildSessionFactory();
Unfortunately, that line throws exception:
{the invoked member is not supported in a dynamic assembly.}
Is there any workaround? How can I create type at runtime and map to retreive data from DB? If it is not possible, how can I use CRUD operations where entity is dictionary (key - column name, value - cell value)? I'd like to avoid executing sql query manually.

I've found sth: click! User hazzik claims that "it is possible and will work" but doesn't explain how. Any help?
Developer
May 23, 2013 at 8:15 PM
Interesting. What exactly is the case you want to solve this way? The issue is that NHibernate is tied in to Orchard in a way that you need to use static record classes for each table, so I really think that exactly this can just work on the lower levels of NHibernate - as you tried.
May 23, 2013 at 8:43 PM
Edited May 23, 2013 at 8:43 PM
The main reason is that I want to avoid creating sql queries in code (or stored procedures - I've done it in that way as for now) and let nhibernate take care of constructing sql queries proper for DB provider.
(...) this can just work on the lower levels (...)
Yeah, I've tried and it doesn't seems to work... even with creating mapping manually.
Anyway, thanks for a reponse!