title: Parsing Azure Analysis Response to a JSON in Azure function using ADOMDClient
body: <p>I am using Microsoft.AnalysisServices.AdomdClient.dll file to connect to Azure Analysis Service for executing DAX queries in Azure function and I need it to spit out in a JSON. Below is how am doing but when there are vast records I see delay in converting the response to json. Analysis service response in 2 secs but masking the response to json is taking more than 40secs. Can someone help suggesting a better way</p>
  
  <pre><code>AdomdCommand cmd = new AdomdCommand(query, _connect);
  public List&lt;Dictionary&lt;string, object&gt;&gt; Results { get; } = new List&lt;Dictionary&lt;string, object&gt;&gt;();
  var reader = cmd.ExecuteReader();
  var schemeTable = reader.GetSchemaTable();
  ISet&lt;string&gt; columnSet = new HashSet&lt;string&gt;();
  foreach (DataRow row in schemeTable.Rows)
  {
   String columnName = row[0].ToString();
   columnSet.Add(columnName);
  }
  while (reader.Read())
  {
   Dictionary&lt;string, object&gt; columns = new Dictionary&lt;string, object&gt;();
   foreach (string columnName in columnSet)
   {
   var value = reader[reader.GetOrdinal(columnName)];
   if (value != null)
   {
    columns.Add(columnName, value);
   }
   else
   {
    columns.Add(columnName, null);
   }
  }
   Results.Add(columns);
  }
  JsonConvert.SerializeObject(Results)
  </code></pre>