nhibernate跨机延迟加载问题

发布于 2024-08-13 04:01:30 字数 116 浏览 3 评论 0原文

我有一个客户端、一个服务器和一个数据库 db 使用流畅的 nhibernate 映射到服务器。 到目前为止,一切都很好 客户端通过wcf与服务器进行对话。 我想在客户端实现延迟加载。

有什么解决办法吗?

i got a client a server and a db
db mapped to server with fluent nhibernate.
so far so good
the client talks with the server with wcf.
i want to implement lazy loading on client side.

is there any solution out there?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

娇女薄笑 2024-08-20 04:01:31

WCF 的本质是在发送之前了解数据的形成,即数据已被检索并放入某种数据契约中。

也许您可以在初始服务调用中提供一个参数来指示是否应填充子属性,尽管您要填充多远总是很棘手。

The nature of WCF would be to learn towards your data being shaped prior to sending, ie., it's already been retreived and put into a datacontract of some sort.

Possibly you could provide a parameter on the inital service call to indicate whether child properties should be populated, although how far you go is always going to be tricky.

沉鱼一梦 2024-08-20 04:01:31

当我意识到这不可能发生时,我决定使用投影和结果转换器。

效果很好。

如果我需要加载一些延迟加载集合,我只需在服务器上迭代它并将其发送回客户端,
当我想更新部分选定的对象时,我必须从数据库中重新选择他并更新完整的数据实体。

但这是值得的

when i realized that it can't happen, i decided to work with the projection and the result transformer.

it works good.

if i need to load some lazy loading collection i just iterate it on server and send it back to client,
when i wanna update a partially selected object i have to reselect him from db and update the full data entity.

but it's worth it

一直在等你来 2024-08-20 04:01:31

抱歉,我很悲观,但让 NHibernate 通过 WCF 进行延迟加载是无法工作的。

I'm sorry to be pessimistic but making NHibernate work with lazy loading over WCF is NOT GOING TO WORK.

何其悲哀 2024-08-20 04:01:31

使用以下代码,WCF 可以使用延迟加载:

var proxy = myObj as INHibernateProxy;
myObj = (myObj)proxy.HibernateLazyInitializer.GetImplementation();

With the below code WCF can work with lazy loading:

var proxy = myObj as INHibernateProxy;
myObj = (myObj)proxy.HibernateLazyInitializer.GetImplementation();
尐偏执 2024-08-20 04:01:30

AFAIK 没有解决方案,延迟加载与 nhibernate 的代理机制一起工作,这对于其实现来说是非常固有的。
有一个名为 Nhibernate.Remote 的项目,但该项目已被放弃。
nhibernate 可以通过 wcf 工作,但没有延迟加载。

AFAIK there is no solution for that, lazy loading works with nhibernate's proxy mechanism which is very intrinsic to its implementation.
there was one project called Nhibernate.Remote but this has been abandoned.
nhibernate would work over wcf, but without lazy loading.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文