views:

260

answers:

5

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?

+2  A: 

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.

A: 

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.

MattC
A: 

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

Chen Kinnrot
A: 

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

Andrei Rinea
i understand you positions but the other fellows here posted some nice links with stuff that work.. but not good enougth for enterprise applications...
Chen Kinnrot
A: 

with below code wcf can work with lazy loadin :

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

maryam