How do I map nested generics in NHibernate

Posted by Gluip on Stack Overflow See other posts from Stack Overflow or by Gluip
Published on 2010-02-03T17:31:32Z Indexed on 2010/03/14 10:05 UTC
Read the original article Hit count: 162

Filed under:
|

In NHibernate you can map generics like this

<class name="Units.Parameter`1[System.Int32], Units" table="parameter_int"  >
</class>

But how can I map a class like this?

Set<T> where T is a Parameter<int> like this Set<Parameter<int>>

My mapping hbm.xml looking like this fails

<class name="Set`1[[Units.Parameter`1[System.Int32], Units]],Units"  table="settable"/> 

I simplified my mappings a little to get my point accross very clearly. Basically I want NHibernate to map generic class which has has generic type parameter.

Want I understand from googling around is that NHibernate is not able to parse the name to the correct type in TypeNameParser.Parse() which result in the following error when adding the mapping to the configuration

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: typeName@31

Anybody found a way around this limitation?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about generics