DataContext & Performance

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Posts: 17
Joined: Fri 04 Nov 2011 16:43
Location: Italia

DataContext & Performance

Post by luigisaggese » Tue 15 Nov 2011 11:28

Since we are working in a distributed environment with many users and many tables to be queried (about 200) we decided to use the following software solution:

- For read operations use DataContext as a singleton.
- For write operations use n different DataContext per business object.

In this way we are experiencing the following problems:

- write operations occur properly, but when I try to read results are not updated to my last submit change.

We have tried to set ObjectTrackingEnabled to false or groped to clear cache on the DataContext but this has not yielded the expected results.

Can you give us support?
How do you recommend to use the n DataContext to write and the only DataContext to read?
How can I clear the cache data?

P.s. My previous step was to use DataContext embraced in using statement per business object but there is memory leak problem as reported[/b]

Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 17 Nov 2011 17:59

Whether object tracking is enabled or not, DataContext caches the retrieved entities to make access to them faster. There is no public interface for clearing the entity cache.

To get the actual state of an object (or an object collection) from the database, you can call the Refresh method with the OverwriteCurrentValues mode.

Generally, if the cached data often becomes stale during the application lifetime, it is recommended to use short-living DataContext instances for reading as well.

Post Reply