You are right about the disposal of the IObjectScope. Let me provide some further details on the topic. Whenever you need to access or modify a property of an object retrieved by an IObjectScope you need to have the same object scope active.
The ObjectContainer is best suited for web scenarios. Its main benefit is that it is serializable and you can transport objects easily across the network without the need to worry about synchronization issues. Therefore, a disconnected environment with asynchronous interaction is where the ObjectContainer really shines. In your case you need to handle a collection of objects which are retrieved in memory. Enabling the second level caching mechanism can provide you a great boost to performance as you can retrieve commonly used objects fast.
The one-scope-per-thread approach is fine in your case and this is the scenario that is recommended for most of the cases. As long as this holds, it is not a problem for the scope to exist for a long time. The connections to the database are managed with connection pooling so the only thing you need to worry about is how to correctly reflect changes made by other threads’ scopes. Each scope has its own level one cache. When you call the scope.Transaction.Begin() method the cache is refreshed when the option RefreshReadObjectsInNewTransaction is set to true. This is the default behavior. If you modify some of the commonly used objects with other scopes you need to refresh the objects in this cache by calling the refresh method of the scope. This step is necessary when you display objects in the UI which haven’t been updated for a long time. The long-living scopes need to be reminded that there are changes made by other scopes.
Again, let me remind you that with the Entity Diagrams context transaction management is handled automatically. Besides, you can retrieve objects from this context, dispose of it, access the properties of the objects and even make changes but you cannot commit them directly. You still need to retrieve corresponding objects from a context and update them while the context is active.
You can browse our online documentation for related topics:
If you want to know more about the ObjectContainer you can have a look at the following blog post
Should you need further assistance, do not hesitate to contact us back.
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Public Issue Tracking
system and vote to affect the priority of the items