title: How can I export all table all records in a database into json using C#
body: <p>I am creating a ERP tool for a supermarket. The owner has two supermarkets in two different places. So, to manage the supermarket the local database (mySQL) should be synchronized to the web server. 
  Currently I am using the following C# code to export all records of a table(<code>sales_products</code>) from my database by filtering the records using columns <code>added_on</code> and <code>last_updated</code>. My database contains more than 20 tables and more records.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
          string json = string.Empty;
          List&lt;object&gt; objects = new List&lt;object&gt;();
          MySqlConnection _dbConnection = new MySqlConnection("Server = localhost; Database = app_erp_suneka; Uid = root; Pwd = ;");
          {
             _dbConnection.Open();// .Open();
             using (MySqlCommand command = _dbConnection.CreateCommand())
              {
                  command.CommandText = "SELECT * FROM sales_products";
                  using (MySqlDataReader reader = command.ExecuteReader())
                  {
                      while (reader.Read())
                      {
                          IDictionary&lt;string, object&gt; record = new Dictionary&lt;string, object&gt;();
                          for (int i = 0; i &lt; reader.FieldCount; i++)
                          {
                              record.Add(reader.GetName(i), reader[i]);
                          }
                          objects.Add(record);
                      }
                  }
              }
          }
          json = JsonConvert.SerializeObject(objects);
          using (StreamWriter sw = new StreamWriter(File.Create(@"C:\Users\SAKTHY-PC\Desktop\path.json")))// "C:\\path\\file.json")))
          {
              sw.Write(json);
          }
  }
  </code></pre>
  
  <p><strong>My Question is:</strong></p>
  
  <p>How can I export all records to json file from <code>all tables</code> using C# ?</p>