流畅的 NHibernate 自动映射
我只是想知道是否可以使用 Fluent NHibernate 自动映射 .Net TcpClient 对象?
我有一个类,它有一个我想映射的 TcpClient 属性。
我尝试创建一个继承自 TcpClient 的自定义类(称为 tTcpClient),并添加带有 getter/setter 的 Id 属性;然而,它仍在寻找基类的 Id 字段。
如果可能的话,任何人都有任何想法,或者我是否需要为 TcpClient 创建自己的 xml 映射?
我有点希望能够保存该对象,以便在重新加载应用程序时轻松地重新创建它,并将 TcpClient 对象的属性绑定到 PropertiesGrid,并允许通过相当简单的配置。
谢谢。
I was just wandering if it would be possible to use the Fluent NHibernate to auto map a .Net TcpClient object?
I have a class that has a TcpClient property which I would like to map.
I tried creating a custom class inheriting from TcpClient called tTcpClient and adding an Id Property with a getter/setter; however, it was still looking for the Id field for the base class.
Anyone have any ideas if it is possible, or will I need to create my own xml mapping for the TcpClient?
I was sort of hoping to be able to save the object to easily recreate it on reloading the application and to bind the properties of the TcpClient object to the PropertiesGrid and allowing configuration through that rather easy.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NHibernate 不知道如何处理像 TcpClient 这样开箱即用的复杂类型。但它允许您提供自己的加载和存储代码。您可以使用 IUserType:
并在 hbm 中像这样映射它:
或者使用流畅的 UserTypeConvention:
NHibernate does not know how to deal with complex types like TcpClient out of the box. But it lets you provide your own loading and storing code. You can use IUserType:
And map it like this in hbm:
Or use fluent UserTypeConvention:
内森,
你看过这个项目吗?
http://automapper.org/
干杯
Nathan,
Have you had a look at this project?
http://automapper.org/
Cheers