How to get NHibernate.Type.IType from a Type?

橙三吉。 提交于 2019-12-08 18:43:52

问题


I try to do the following:

hibQuery.SetParameter("MyParameter", valueObject, valueType);

The only problem is that this method expects NHibernate.Type.IType in the third parameter, but valueType is of type Type. How could I convert this to IType?

Thx for any tipps sl3dg3


回答1:


Try the built-in NHibernateUtil.GetSerializable() method. It takes a CLR System.Type and returns the corresponding IType. More documentation: http://elliottjorgensen.com/nhibernate-api-ref/NHibernate/NHibernateUtil.html#M:NHibernate.NHibernateUtil.GetSerializable%28System.Type%29




回答2:


Check out the NHibernate.Type.TypeFactory.GetSerializableType() method.




回答3:


Use NHibernateUtil.GuessType method.

NHibernate.Type.IType type = NHibernateUtil.GuessType(typeof(T));



回答4:


You can use the fields/methods from the NHibernate.NHibernateUtil helper class.



来源:https://stackoverflow.com/questions/5182934/how-to-get-nhibernate-type-itype-from-a-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!