InvalidOperationExceptions after passing entities through web service

Posts   
 
    
shennig
User
Posts: 48
Joined: 14-Nov-2006
# Posted on: 07-Jul-2010 18:24:17   

hi,

i'm using Gen Pro Version 3.0 Final (with selfservicing) for a ms sql server 2008 database in a client server scenario (.net 3.5 sp1), in wich entities are loaded on the server an passed with web services (wcf) to the client. only the server has a connection to the database.

now the problem: if i load an existing entity or create a new one on the server and send it via wcf to the client, i cant't access the collection properties to related entities. there comes an InvalidOperationException with the message "the connection was not initialized". as far as i understand, the entity tries to (lazy) load the related entities, but has no connection to the database. but i don't want to lazy load the objects on client. if they are not loaded on server, a collection should be null or empty.

how can i transfer an entity via wcf without getting InvalidOperationExceptions by accessing properties from the entity?

best regards,

shennig

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Jul-2010 05:44:24   

Hi shennig,

I assume for the description, that you are using SelfServicing. In that kind of scenarios is better to use Adapter or send DTO's instead of Entities.

The thing is that in SelfServicing, LLBLGen tries to lazy load related entities, that is unavoidable as it is how SelfServincing works. Any change you change to Adapter?

David Elizondo | LLBLGen Support Team
shennig
User
Posts: 48
Joined: 14-Nov-2006
# Posted on: 08-Jul-2010 07:26:56   

thanks daelmo.

you're right. adapter is the better thing to use. i've saw a hint after i've written th post and tried it. it works better.