/// <summary>
        /// Executes the query and returns a JSON string from data set returned by the query.
        /// </summary>
        /// <param name="dataCommand">The data command.</param>
        /// <param name="options">The <see cref="JsonWriterOptions"/> options.</param>
        /// <returns>A JSON string representing the <see cref="IDataReader"/> result of the command.</returns>
        public static string QueryJson(this IDataCommand dataCommand, JsonWriterOptions options = default)
        {
            using var stream = new MemoryStream();
            using var writer = new Utf8JsonWriter(stream, options);

            writer.WriteStartArray();

            dataCommand.Read(reader =>
            {
                while (reader.Read())
                {
                    writer.WriteStartObject();

                    for (int index = 0; index < reader.FieldCount; index++)
                    {
                        var name = reader.GetName(index);
                        writer.WritePropertyName(name);

                        WriteValue(reader, writer, index);
                    }

                    writer.WriteEndObject();
                }
            });

            writer.WriteEndArray();

            writer.Flush();

            return(Encoding.UTF8.GetString(stream.ToArray()));
        }