Up DevForce development

Take offline

Last modified on October 21, 2011 12:46

DevForce’s client-side cache enables applications to operate in a partially connected or fully disconnected environment. You can query, modify, and even create new entities while offline, and you can save the cache to the file system to preserve the state of the entities if the application or computer needs to be shut down.

Query entities offline

With a few small exceptions, the same LINQ queries you execute while connected will work disconnected, except that they will be fulfilled entirely from the client-side cache. While disconnected, the EntityManager will use a QueryStrategy of CacheOnly for all queries since the EntityServer is not available. (To learn more about QueryStrategies, see Control query execution.)

Create, modify, and delete entities offline

Creating and modifying entities is not affected by being disconnected, as these are purely client-side operations until they are committed to the server by SaveChanges or SaveChangesAsync. Similarly, you can mark the deletion of an entity while disconnected, and the EntityState will change to Deleted, but the entity will not be committed until the save.

Connect and Disconnect

You can tell the EntityManager to enter the disconnected state by calling the Disconnect method. When network access is restored, you can reconnect by calling Connect or ConnectAsync. While disconnected, the IsConnected property will return false.

If the EntityManager is in the connected state and it experiences a loss of connection, it will:

  1. Enter into the disconnected state.
  2. Raise the EntityServerError event with an EntityServerConnectionException in the EntityServerErrorEventArgs, which you should handle and indicate to the user.
  3. Throw an EntityServerConnectionException if the EntityServerErrorEventArgs was not marked as handled in the EntityServerError event.

When creating a new EntityManager while offline, you should pass false for the shouldConnect parameter. This will keep the EntityManager from automatically attempting to establish a connection to the entityserver.

Created by DevForce on March 07, 2011 12:22

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2012 IdeaBlade