DevForce Help Reference
EntityCacheState Class
Members  Example 


A serializable collection of Entities that can be retrieved from an EntityManager.
Syntax
'Declaration
 
<DataContractAttribute()>
Public Class EntityCacheState 
'Usage
 
Dim instance As EntityCacheState
[DataContract()]
public class EntityCacheState 
Remarks
An EntityCacheState is retrieved from an EntityManager via the CacheStateManager.GetCacheState method; it can then be serialized and stored. The EntityCacheState can be restored by deserializing the contents and calling either the Merge or CacheStateManager.RestoreCacheState methods.

The SaveCacheState(String,Boolean) and RestoreCacheState(String,Boolean) methods of the IdeaBlade.EntityModel.EntityCacheManager class provide additional serialization and deserialization capabilities. You can use EntityCacheState directly if you prefer additional control over this processing. You will normally work with the EntityCacheState via the EntityManager's EntityManager.CacheStateManager property.

Example
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>();
}
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
Inheritance Hierarchy

System.Object
   IdeaBlade.EntityModel.EntityCacheState

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityCacheState Members
IdeaBlade.EntityModel Namespace
EntityManager Class
CacheStateManager Class

Send Feedback