public virtual async Task <IDbConnection> OpenDbConnectionAsync(string namedConnection, CancellationToken token = default(CancellationToken))
        {
            var connection = CreateDbConnection(namedConnection);

            if (connection is OrmLiteConnection ormliteConn)
            {
                await ormliteConn.OpenAsync(token);

                return(connection);
            }

            await DialectProvider.OpenAsync(connection, token);

            return(connection);
        }
Example #2
0
        public async Task OpenAsync(CancellationToken token = default(CancellationToken))
        {
            if (DbConnection.State == ConnectionState.Broken)
            {
                DbConnection.Close();
            }

            if (DbConnection.State == ConnectionState.Closed)
            {
                await DialectProvider.OpenAsync(DbConnection, token);

                //so the internal connection is wrapped for example by miniprofiler
                if (Factory.ConnectionFilter != null)
                {
                    dbConnection = Factory.ConnectionFilter(dbConnection);
                }

                DialectProvider.OnOpenConnection?.Invoke(dbConnection);
            }
        }