问题描述
我有我的WCF服务层使用与NHibernate一个POCO类。而且我想尝试发送NHibernate的代理类下降到客户端。这是我控制的客户端。我们处理记录更新了系统,广泛的预订所以只能发送到客户端,在任何给定时间这个实体的一个可写副本。我的基本目标是利用NHibernates更改跟踪,所以我并不需要从数据库中获取副本,并重播所作的更改更新数据库客户端。
I have a POCO classes that I am using with NHibernate in a WCF service layer. And I am thinking about trying to send the NHibernate proxy classes down to a client. This is a client that I control. We handle record updates with a system wide reservation so there can only be one writable copy of this entity sent to a client at any given time. My basic goal is to take advantage of NHibernates change tracking so I don't need to fetch a copy from the database and replay the changes the client made to update the db.
假设我能得到这个工作有什么这个approch的缺点是什么?
Assuming I could get this to work what are the cons of this approch?
推荐答案
延迟加载会给你最头痛的问题。
Lazy-loading will give you the biggest headache.
一些上你的对象的属性将包含NHibernate的代理,它们分别连接到的ISession。所有这一切将旅行返回给客户端。当客户端尝试deserialise你的对象,在代理被调用,并尝试获取更多的数据。嘭!
Some of the properties on your objects will contain NHibernate proxies, which are attached to the ISession. All of this will travel back to the client. When the client attempts to deserialise your objects, the proxies get invoked and attempt to retrieve more data. BOOM!
有几种解决方法的人都贴(谷歌的 NHibernate的WCF 的或 NHibernate的WCF延迟加载的):
There are several workarounds people have posted (Google "nhibernate wcf" or "nhibernate wcf lazy loading"):
的http:// lunaverse .word press.com / 2007/05/09 /远程-使用WCF的 - 和 - 的NHibernate /
的
http://whiletrue.nl/blog/?p=37
http://trentacular.com/2009/08/how-to-use-nhibernate-lazy-initializing-proxies-with-web-services-or-wcf/
我目前正在对换出与自定义的代理服务器,因此他们会触发NHibernate的延迟加载的WCF调用。
I'm currently working on swapping out the proxies with custom ones, so they make a WCF call instead of triggering the Nhibernate lazy-load.
这篇关于什么是与发送Hibernate的代理类客户有关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!