相关疑难解决方法(0)

实体框架使用了大量内存

这是来自ANTS内存分析器的图像.它认为内存中有很多对象.我怎么能找到我做错了什么?

ANTS内存分析器

**UPDATE**
Run Code Online (Sandbox Code Playgroud)

这是我的存储库类:

public class Repository<T> : IRepository<T> where T : class, IDataEntity
    {
        ObjectContext _context;
        IObjectSet<T> _objectSet;

        readonly string _entitySetName;
        readonly string[] _keyNames;

        private ObjectContext Context
        {
            get
            {
                if (_context == null)
                {
                    _context = GetCurrentUnitOfWork<EFUnitOfWork>().Context;
                }
                return _context;
            }
        }

        private IObjectSet<T> ObjectSet
        {
            get
            {
                if (_objectSet == null)
                {
                    _objectSet = this.Context.CreateObjectSet<T>();
                }
                return _objectSet;
            }
        }

        public TUnitOfWork GetCurrentUnitOfWork<TUnitOfWork>() where TUnitOfWork : IUnitOfWork
        {
            return (TUnitOfWork)UnitOfWork.Current;
        }

        public virtual IEnumerable<T> GetQuery()
        {
            return ObjectSet; …
Run Code Online (Sandbox Code Playgroud)

.net c# performance linq-to-entities entity-framework

13
推荐指数
2
解决办法
1万
查看次数