mlens:
Are you sure you have some User entities in the cache when you run your query?
i just tested a cache-only query using the following method (having previously saved some Employees to the Data.bin file):
private void TestLoginManager(){ _mgr.CacheStateManager.RestoreCacheState("Data.bin"); List<Employee> employees = _mgr.Employees.With(QueryStrategy.CacheOnly).ToList(); // List<Employee> employees = _mgr.Employees.ToList(); Console.WriteLine("Retrieved {0} Employees from cache", employees.Count); //_mgr.CacheStateManager.SaveCacheState("Data.bin"); PromptToContinue(); }
|
LoginManagerRequired was set to true in the exe project's app.config. LoginManager as follows:
class LoginManager:IEntityLoginManager { #region IEntityLoginManager Members
public System.Security.Principal.IPrincipal Login(ILoginCredential credential, EntityManager entityManager) { throw new NotImplementedException(); //return new WindowsPrincipal(WindowsIdentity.GetCurrent()); }
public void Logout(System.Security.Principal.IPrincipal principal, EntityManager entityManager) { throw new NotImplementedException(); }
#endregion }
|
Login() is called in this LoginManager if DevForce tries to access the EntityServer. (You can verify this by substituting the version of the query with no call to With(QueryStrategy.CacheOnly). It throws an exception.)
The above test method, in the form shown, successfully reports 9 Employees in the list.