I'm trying to use webservices with lazy loaded collections. This works fine except for the fact that the lazy collections get loaded when serializing the object. I don't want the collection initialized immediately, but only by calling a webmethod that reattaches the object and initializes the collection.
I guess this happens because when serializing the object, the collection property is accessed. Is there a work-around? Do I have to check whether the collections is already initialized and if not, not serialize it?
Example of mapping file:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Person" table="PERSONS">
<id name="ID" type="Int32" column="ID">
<generator class="identifier" />
</id>
<bag name="Addresses" inverse="true" lazy="true">
<key column="Address" />
<one-to-many class="Address" />
</bag>
</class>