1

アプリケーションが呼び出すたびに、一貫して繰り返し可能な 120 秒のハングが発生します

 this.cacheProvider.Add(new CacheItem(cacheKey, data, this.regionName), cachePolicy);

サンプルの CachedDataSource.cs の60 行目。. メソッドは Microsoft の DLLの.Add内部にあり、コードはありません。ここに私のパラメータがあります:

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 に追加して、最近 4.1 にアップグレードしたデータベース ファーストの EF4.0 プロジェクトがあります。

これらの変更を元に戻すと、アプリケーションはすぐにパフォーマンスが向上します。

DAL とリポジトリは、MVC アプリケーションとは別の DLL に格納されています。これが問題の一部であるかどうかはわかりません。

私のリポジトリについて

    /// 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);
        }
    }

質問

これはバグですか、それとも EF4.1 を使用しているか、またはキャッシュ レイヤーを間違って使用していますか?

4

1 に答える 1

0

データは IQueryable の結果であると述べています。データをキャッシュに送信する前に、最初にデータに対して .ToList() を実行しようとしましたか?

于 2011-11-15T14:00:31.863 に答える