IdeaBlade DevForce 2010 Help Reference
CacheStateManager Class
Members  Example  See Also  Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace : CacheStateManager Class



Used to store and retrieve the EntityManager's cache from a stream or file.

Syntax

Visual Basic (Declaration) 
Public Class CacheStateManager 
Visual Basic (Usage)Copy Code
Dim instance As CacheStateManager
C# 
public class CacheStateManager 
C++/CLI 
public ref class CacheStateManager 

Example

C#Copy Code
private void SampleEntityCacheUsage() {

   DomainModelEntityManager mgr = new DomainModelEntityManager();

   // Cache all employees.
   mgr.ExecuteQuery<Employee>();

   // Save the cache to local storage.
   mgr.CacheStateManager.SaveCacheState(@"c:\temp\entitycache.bin");

   // Ocassionally-connected users will normally connect, cache all data required,
   // then disconnect and work from local cache and/or locally saved cache until they can reconnect.
   // In this example, we'll mimic a disconnected login for this user by clearing all cached data
   // and then re-loading the cache from local storage.
   mgr.Disconnect();
   mgr.Clear();

   mgr.CacheStateManager.RestoreCacheState(@"c:\temp\entitycache.bin");

   // Let's reconnect and get more data now.
   mgr.Connect();
   mgr.ExecuteQuery<Customer>();
}
Visual BasicCopy Code
Private Sub SampleEntityCacheUsage()

  Dim mgr As New DomainModelEntityManager()

  ' Cache all employees.
  mgr.ExecuteQuery(Of Employee)()

  ' Save the cache to local storage.
  mgr.CacheStateManager.SaveCacheState("c:\temp\entitycache.bin")

  ' Ocassionally-connected users will normally connect, cache all data required,
  ' then disconnect and work from local cache and/or locally saved cache until they can reconnect.
  ' In this example, we'll mimic a disconnected login for this user by clearing all cached data
  ' and then re-loading the cache from local storage.
  mgr.Disconnect()
  mgr.Clear()

  mgr.CacheStateManager.RestoreCacheState("c:\temp\entitycache.bin")

  ' Let's reconnect and get more data now.
  mgr.Connect()
  mgr.ExecuteQuery(Of Customer)()
End Sub

Remarks

You can access the CacheStateManager used by an EntityManager through the EntityManager.CacheStateManager property. Use SaveCacheState(String,Boolean) to store the entity cache to an external source, and RestoreCacheState(String,Boolean) to restore a previously saved cache.

Inheritance Hierarchy

System.Object
   IdeaBlade.EntityModel.CacheStateManager

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.