private static async Task <T> ExecuteCommandAsync <T>(
            SpannerConnection connection, Func <DbCommand, Task <T> > executeAsync, string sql, bool useTransaction,
            IReadOnlyList <object> parameters)
        {
            if (connection.State != ConnectionState.Closed)
            {
                connection.Close();
            }
            await connection.OpenAsync().ConfigureAwait(false);

            try
            {
                using (var transaction = useTransaction ? connection.BeginTransaction() : null)
                {
                    T result;
                    using (var command = CreateCommand(connection, sql, parameters))
                    {
                        result = await executeAsync(command).ConfigureAwait(false);
                    }
                    transaction?.Commit();

                    return(result);
                }
            }
            finally
            {
                if (connection.State == ConnectionState.Closed &&
                    connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        private static T ExecuteCommand <T>(
            SpannerConnection connection, Func <DbCommand, T> execute, string sql, bool useTransaction,
            object[] parameters)
        {
            if (connection.State != ConnectionState.Closed)
            {
                connection.Close();
            }
            connection.Open();
            try
            {
                using (var transaction = useTransaction ? connection.BeginTransaction() : null)
                {
                    T result;
                    using (var command = CreateCommand(connection, sql, parameters))
                    {
                        command.Transaction = transaction;
                        result = execute(command);
                    }
                    transaction?.Commit();

                    return(result);
                }
            }
            finally
            {
                if (connection.State == ConnectionState.Closed &&
                    connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
                //To debug the parse error, set SkipToLine= this value.
                Trace.WriteLine($"Error encountered at statement {s_gStatements}");
            }
        }