NHibernate mapping System.Type
When I map an entity that has a property of type System.Type, I know that NHibernate maps this to DbType.String, holding Assembly Qualified Name, and I can see that in the table, the type column holds values like "TarkusSoftware.Abstract.ITask, TarkusSoftware.Abstract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".
What does this mean for long-term development, what will happen when we eventually change the assembly version for example to 2.0.0.0? I figure NHibernate will fail to hydrate the object, since it won't be able to find the type with its assembly qualified name. In this case, how s开发者_如何学JAVAhould one proceed to mapping System.Type to ensure future compatibility? Thanks :)
That is probably correct. You can implement your own IUserType to be more in control.
I just checked NH source, you are right. It only uses the type and assembly name, ignoring version, etc. If interested, check the code in: TypeNameParser.Parse()
精彩评论