void WriteDataReader(StringBuilder sb, IDataReader reader)
{
if (reader == null || reader.FieldCount == )
{
sb.Append("null");
return;
}
int rowCount = ;
sb.Append("{\"Rows\":[\r\n");
while (reader.Read())
{
sb.Append("{");
for (int i = ; i < reader.FieldCount; i++)
{
sb.Append("\"" + reader.GetName(i) + "\":") ;
this.WriteValue(sb,reader[i]);
sb.Append(",");
if (this.FormatJsonOutput)
sb.Append("\r\n");
}
// strip off trailing comma
if (reader.FieldCount > )
this.StripComma(sb);
sb.Append("},");
if (this.FormatJsonOutput)
sb.Append("\r\n");
rowCount++;
}
// remove trailing comma
if (rowCount > )
this.StripComma(sb);
sb.Append("]}");
}