Beispiel #1
0
            protected override bool Dispose(bool disposing)
            {
                if (_pool != null)
                {
                    //归还时如果缓冲池已满,则要进行销毁
                    if (!_pool.Return(Context))
                    {
                        ((IObjectPoolable)Context).SetPool(null);
                        Context.TryDispose(disposing);
                    }

                    _pool   = null;
                    Context = null;
                }

                return(base.Dispose(disposing));
            }
Beispiel #2
0
            /// <summary>
            /// 初始化 <see cref="Lease"/> 类的新实例。
            /// </summary>
            /// <param name="pool"></param>
            public Lease(IServiceProvider serviceProvider, EntityContextPool <TContext> pool)
            {
                _pool = pool;

                Context = _pool.Rent(serviceProvider);
            }