Hi,
I'm not able to retrieve data I've cached locally. The second block of code (below) works fine when I am connected to the database. However, when I am not
connected to the database I get a "Sequence contains no elements"
error. The stack trace is at the bottom.
Here is the code used to save the cache state (seems to work fine):
EntityQuery<LOCAL_STRING> localStringQuery = null;
localStringQuery =
(from ls in domainEntityManagerService.DomainEntityManager.LOCAL_STRING
select ls);
domainEntityManagerService.DomainEntityManager.CacheStateManager.SaveCacheState("c:\localization.bin");
|
Here is the code used to query the table/cache. The RestoreFromCache()
method works fine -- it is the line in red throwing the
exception. I may be going about this the wrong way, so hopefully
someone can't point me in the right direction. Is it not possible to use LINQ queries against locally cached data? Thanks!
private EntityQuery<LOCAL_STRING> localStringQuery = null;
public object GetValue(string localKey)
{
try
{
if (domainEntityManagerService.DomainEntityManager.IsConnected == false &&
domainEntityManagerService.DomainEntityManager.IsLoggedIn == false)
{
domainEntityManagerService.DomainEntityManager.DefaultQueryStrategy = QueryStrategy.CacheOnly;
domainEntityManagerService.DomainEntityManager.CacheStateManager.RestoreCacheState("c:\localization.bin");
}
localStringQuery =
(from ls in domainEntityManagerService.DomainEntityManager.LOCAL_STRING
where ls.LOCAL_KEY == localKey
select ls);
return localStringQuery.First().LOCAL_TEXT;
}
catch ( Exception ex )
{
...
}
return null;
}
|
" at System.Linq.Enumerable.First[TSource](IEnumerable`1
source)\r\n at lambda_method(ExecutionScope )\r\n at
System.Linq.EnumerableExecutor`1.Execute()\r\n at
System.Linq.EnumerableExecutor`1.ExecuteBoxed()\r\n at
System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute(Expression
expression)\r\n at
IdeaBlade.EntityModel.v4.EntityQuery`1.ExecuteCacheQuery(Guid
queryGuid)\r\n at
IdeaBlade.EntityModel.v4.EntityQueryFinder.ExecuteFind(Guid
queryGuid)\r\n at
IdeaBlade.EntityModel.v4.EntityQueryFinder.Execute()\r\n at
IdeaBlade.EntityModel.v4.EntityManager.ExecuteQueryCore(IEntityQuery
query, Boolean isAsync)\r\n at
IdeaBlade.EntityModel.v4.EntityManager.ExecuteQueryForObject(IEntityQuery
query)\r\n at
IdeaBlade.EntityModel.v4.EntityQuery`1.System.Linq.IQueryProvider.Execute[TResult](Expression
expression)\r\n at System.Linq.Queryable.First[TSource](IQueryable`1
source)\r\n at
Jenzabar.EX.Infrastructure.Localization.LocalizationProvider.GetValue(String
localKey) in C:\\Documents and
Settings\\...\\LocalizationProvider.cs:line 79"