开发者

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

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 T开发者_运维百科ype. How could I convert this to IType?

Thx for any tipps sl3dg3


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


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


Use NHibernateUtil.GuessType method.

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜