How do I map nested generics in NHibernate
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 Pa开发者_Go百科rameter<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?
I think you'll have to map it as a custom type. See this article and google for IUserType.
精彩评论