public Task <IDbTransaction> GetActiveTransactionAsync(ActiveTransactionProviderArgs args)
        {
            var adoTransaction = _sessionProvider.Session.GetCurrentTransaction().As <AdoTransaction>();
            var dbTransaction  = GetFieldValue(typeof(AdoTransaction), adoTransaction, "trans").As <IDbTransaction>();

            return(Task.FromResult(dbTransaction));
        }
예제 #2
0
        public IDbTransaction GetActiveTransaction(ActiveTransactionProviderArgs args)
        {
            var adoTransaction = GetSession(args).Transaction.As <AdoTransaction>();
            var dbTransaction  = GetInstanceField(typeof(AdoTransaction), adoTransaction, "trans").As <IDbTransaction>();

            return(dbTransaction);
        }
        public IDbTransaction GetActiveTransaction(ActiveTransactionProviderArgs args)
        {
            var adoTransaction = _sessionProvider.Session.Transaction.As <AdoTransaction>();
            var dbTransaction  = GetFieldValue(typeof(AdoTransaction), adoTransaction, "trans").As <IDbTransaction>();

            return(dbTransaction);
        }
예제 #4
0
 public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
 {
     if (Session.Connection.State == ConnectionState.Closed)
     {
         Session.Connection.Close();
     }
     return(Session.Connection);
 }
예제 #5
0
        private DbContext GetDbContext(ActiveTransactionProviderArgs args)
        {
            var    dbContextType         = (Type)args["ContextType"];
            Type   dbContextProviderType = typeof(IDbContextProvider <>).MakeGenericType(dbContextType);
            object dbContextProvider     = _scopeResolver.Resolve(dbContextProviderType);
            var    dbContext             = getDbContextMethod.Invoke(dbContextProvider, null).As <DbContext>();

            return(dbContext);
        }
예제 #6
0
        private ISession GetSession(ActiveTransactionProviderArgs args)
        {
            var        sessionContextType     = (Type)args["SessionContextType"];
            var        sessionContextProvider = _scope.Resolve <ISessionProvider>();
            MethodInfo method  = getSessionMethod.MakeGenericMethod(sessionContextType);
            var        session = method.Invoke(sessionContextProvider, null).As <ISession>();

            return(session);
        }
예제 #7
0
        public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
        {
            var connection = DbFactory.CreateConnection();

            connection.ConnectionString = DbContext.ConnectionString;
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }

            return(connection);
        }
예제 #8
0
        private DbContext GetDbContext(ActiveTransactionProviderArgs args)
        {
            Type dbContextProviderType = typeof(IDbContextProvider <>).MakeGenericType((Type)args["ContextType"]);

            using (IDisposableDependencyObjectWrapper dbContextProviderWrapper = _iocResolver.ResolveAsDisposable(dbContextProviderType))
            {
                MethodInfo method = dbContextProviderWrapper.Object.GetType()
                                    .GetMethod("GetDbContext");

                return((DbContext)method.Invoke(dbContextProviderWrapper.Object, new object[0]));
            }
        }
예제 #9
0
        private DbContext GetDbContext(ActiveTransactionProviderArgs args)
        {
            var dbContextProviderType = typeof(IDbContextProvider <>).MakeGenericType((Type)args["ContextType"]);

            using (var dbContextProviderWrapper = iocResolver.ResolveAsDisposable(dbContextProviderType))
            {
                var method = dbContextProviderWrapper.Object.GetType()
                             .GetMethod(
                    nameof(IDbContextProvider <StudioXDbContext> .GetDbContext),
                    new[] { typeof(MultiTenancySides) }
                    );

                return((DbContext)method.Invoke(
                           dbContextProviderWrapper.Object,
                           new object[] { (MultiTenancySides?)args["MultiTenancySide"] }
                           ));
            }
        }
        private async Task <DbContext> GetDbContextAsync(ActiveTransactionProviderArgs args)
        {
            var dbContextProviderType = typeof(IDbContextProvider <>).MakeGenericType((Type)args["ContextType"]);

            using (var dbContextProviderWrapper = _iocResolver.ResolveAsDisposable(dbContextProviderType))
            {
                var method = dbContextProviderWrapper.Object.GetType()
                             .GetMethod(
                    nameof(IDbContextProvider <AbpDbContext> .GetDbContextAsync),
                    new[] { typeof(MultiTenancySides) }
                    );

                var result = await ReflectionHelper.InvokeAsync(method, dbContextProviderWrapper.Object,
                                                                new object[] { (MultiTenancySides?)args["MultiTenancySide"] });

                return(result as DbContext);
            }
        }
        public async Task <IDbTransaction> GetActiveTransactionAsync(ActiveTransactionProviderArgs args)
        {
            var context = await GetDbContextAsync(args);

            return(context.Database.CurrentTransaction.UnderlyingTransaction);
        }
예제 #12
0
 public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
 {
     return(GetDbContext(args).Database.Connection);
 }
예제 #13
0
 public IDbTransaction GetActiveTransaction(ActiveTransactionProviderArgs args)
 {
     return(GetDbContext(args).Database.CurrentTransaction?.UnderlyingTransaction);
 }
 public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 public IDbTransaction GetActiveTransaction(ActiveTransactionProviderArgs args)
 {
     return(Session.CurrentTransaction);
 }
 public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
 {
     return(_sessionProvider.Session.Connection);
 }
 public async Task <IDbConnection> GetActiveConnectionAsync(ActiveTransactionProviderArgs args)
 {
     return(await Task.FromResult(_sessionProvider.Session.Connection));
 }
        public async Task <IDbConnection> GetActiveConnectionAsync(ActiveTransactionProviderArgs args)
        {
            var context = await GetDbContextAsync(args);

            return(context.Database.GetDbConnection());
        }
예제 #19
0
 public IDbTransaction GetActiveTransaction(ActiveTransactionProviderArgs args)
 {
     //return GetActiveConnection(args).BeginTransaction();
     return(null);
 }
예제 #20
0
 public async Task <IDbTransaction> GetActiveTransactionAsync(ActiveTransactionProviderArgs args)
 {
     return(await Task.FromResult(GetActiveTransaction(args)));
 }
 public ISession GetActiveSession(ActiveTransactionProviderArgs args)
 {
     EnsureSession();
     return(_session);
 }
예제 #22
0
 public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
 {
     return(conn);
 }
        public IDbConnection GetActiveConnection(ActiveTransactionProviderArgs args)
        {
            var context = GetDbContext(args);

            return(context.Database.GetDbConnection());
        }
예제 #24
0
        public IDbTransaction GetActiveTransaction(ActiveTransactionProviderArgs args)
        {
            IDbTransaction dbTransaction = conn.BeginTransaction();

            return(dbTransaction);
        }
        public DbContext GetDbContext(ActiveTransactionProviderArgs args)
        {
            DbContext dbContext = (DbContext)DbContext;

            return(dbContext);
        }