This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi mindscape team I have a question regarding the lazyloading of the example below:
On The attributeGroups I have set LazyLoading to true. How is it possible to detect if the EntityCollection "Attributes" is already loaded/materialized? I have tried to use the IsLoaded method, which returns true, but on the last code line an exception is raised that the UnitOfWork is disposed. My Goal is to create a mechanism that the developer has not to care about the attachement of the entity on the unit of work. Or in the case that the developers has forgotten to attach the entity to the unit of work, I automatically open a new unit of work and no exception is raised. Sure, one option is to maintain the unit of work open for the whole session, but the unit of work should be closed asap. Thanks for your help Marco Leonardi |
|
|
You can test the .IsLazy property on the underlying EntityCollection field to determine if the collection is loaded. If you are seeing an object disposed exception this is because the UnitOfWork instance associated with the collections parent entity has been disposed (usually by falling out of scope). Make sure you attach the parent back into the current UnitOfWork scope you are operating on (call UnitOfWork.Attach) or explicitly detach the entity from its UnitOfWork instance (call UnitOfWork.Detach).
|
|