예제 #1
0
        /// <summary>
        /// Get connection async
        /// </summary>
        /// <returns>Async connection</returns>
        public override async Task <DbConnection> GetConnectionAsync()
        {
            var connection = new PgDbConnection(ConnectionString, Logger);
            await connection.OpenAsync();

            return(await Task.FromResult(connection));
        }
예제 #2
0
 private void SetLocale(PgDbConnection connection)
 {
     if (_localeProvider != null)
     {
         using (var cmd = connection.CreateCommand())
         {
             cmd.CommandText = "main.set_language";
             cmd.CommandType = CommandType.StoredProcedure;
             var param = cmd.CreateParameter();
             param.ParameterName = "p_language_id";
             param.Value         = (int)_localeProvider.Locale;
             param.DbType        = DbType.Int32;
             cmd.Parameters.Add(param);
             cmd.ExecuteNonQuery();
         }
     }
 }
예제 #3
0
        /// <inheritdoc />
        public override IDbConnection GetConnection(string connectionString)
        {
            var connection = new PgDbConnection(connectionString, Logger);

            connection.Open();

            // var tz = $"set time zone interval '{TimeZoneInfo.Local.BaseUtcOffset:hh\\:mm}'";
            using (var cmd = connection.CreateCommand())
            {
                cmd.CommandText = "set time zone '00'";
                cmd.ExecuteNonQuery();
            }

            if (_setLocale)
            {
                SetLocale(connection);
            }

            return(connection);
        }