NHibernate lazy-loading over a web service

2019-08-17 21:47发布

问题:

I have a web application that will get domain objects from a web service, which in turn gets them from a database via NHibernate.

I'd like to be able to transfer these objects with uninstantiated members (members that are typically lazy-loaded from the database in the web service) and then have subsequent calls automatically made to the web service when the application code tries to access them. Essentially a process identical to regular NH lazy loading, except with the web service in place of the database server.

Note that this happens within a LAN and with low transaction rates, so I'm not concerned with whatever performance penalty this is likely to have.

I would think that what's needed is first code that gets invoked when serializing to the objects that turns the NH lazy-loading proxy information into something that can be reconstructed on the client side, and then client-side code to deserialize that information into objects of a different proxy type, one that will make a web-service call to retrieve the lazy data when it is referenced.

I would think someone would have developed such a framework already, but I haven't managed to find it, so I figured a direct question was in order.

If you know of any work that's been done in this area, please respond.

Michael