EF4.1使用Microsoft.ApplicationServer.Caching.DataCacheFactory挂起时120秒 [英] EF4.1 hangs for 120 seconds when using Microsoft.ApplicationServer.Caching.DataCacheFactory
问题描述
我有一个一致的,可重复的120秒挂每当应用程序调用
I have a consistent, repeatable 120 second hang whenever the application calls
this.cacheProvider.Add(new CacheItem(cacheKey, data, this.regionName), cachePolicy);
在样本。的 CachedDataSource.cs线60。在。新增
方法是内部微软的DLL和我没有code到它。这里是我的参数:
at line 60 of the CachedDataSource.cs of the sample.. The .Add
method is internal to Microsoft's DLL and I don't have code to it. Here are my parameters:
cacheKey = "listofCompanies"
data = // this is an EF 4.0 database first model class with 70 entries... result from IQueryable
this.regionName = "companies"
重现错误:
我有我最近通过添加的EntityFramework引用和的 ContextGenerator我DAL 。
I have a database-first EF4.0 project that I recently upgraded to 4.1 by adding the "EntityFramework" reference and a ContextGenerator to my DAL.
如果我取消这些变化,然后我的应用程序是当下高性能的。
If I undo these changes, then my application is instantly performant.
我的DAL和资源库存储在一个单独的DLL从我的MVC应用程序。不知道这是打的问题的一部分。
My DAL and repository are stored in a separate DLL from my MVC application. Not sure if this is playing a part of the issue.
关于我的仓库
/// Sample repository. Note that I return List<T> as IEnumerable,
/// and I use IDisposable
///
public class CompanyRepository : DisposableBase, ICompanyRepository
{
public IEnumerable<CompanyDetail> GetOneCompany(int? CompanyID)
{
var t = from c in _entities.CompanyDetail
where c.CompanyID == CompanyID.Value
select c;
return t.ToList();
}
}
/// <summary>
/// Disposable implementation based on advice from this link:
/// from Http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
/// </summary>
public class DisposableBase : IDisposable
{
protected TLSAdminEntities1 _entities;
public DisposableBase()
{
_entities = new TLSAdminEntities1();
disposed = false;
}
private bool disposed ;
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
_entities.Dispose();
}
}
this.disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
问
这是一个bug,还是我使用EF4.1,或缓存层不正确?
Is this a bug, or am I using EF4.1, or the Caching layer incorrectly?
推荐答案
您提到的数据是IQueryable的结果。您是否尝试过在数据传送过它的缓存前先执行.ToList()?
You mention that data is the result of IQueryable. Have you tried to perform .ToList() first on the data before sending it over to cache?
这篇关于EF4.1使用Microsoft.ApplicationServer.Caching.DataCacheFactory挂起时120秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!