public static IServiceCollection AddOryxDbPool <T>(this IServiceCollection services, Func <T> optionsAction)
            where T : class
        {
            //var dboptions = new DbOptions<T>();
            var dbPool = new OryxDatabasePool <T>(optionsAction);

            //var lease = new OryxDatabasePool<T>.Lease(dbPool);
            services.AddSingleton(dbPool);
            services.AddScoped <OryxDatabasePool <T> .Lease>( );
            services.AddScoped(sp => sp.GetService <OryxDatabasePool <T> .Lease>().Context);

            return(services);
        }
Exemplo n.º 2
0
            void IDisposable.Dispose()
            {
                if (_contextPool != null)
                {
                    if (!_contextPool.Return(Context))
                    {
                        //((IDbContextPoolable)Context).SetPool(null);
                        //Context.Dispose();
                    }

                    _contextPool = null;
                    Context      = null;
                }
            }
Exemplo n.º 3
0
 public Lease(OryxDatabasePool <T> contextPool)
 {
     _contextPool = contextPool;
     Context      = _contextPool.Rent();
 }