title: Getting SQL query string from DbCommand with Parameters
body: <p>Just before executing a SQL query on a MySQL database in C# I want to log the query that will be executed. What I have now obviously only logs <code>SELECT * FROM foo WHERE Id = @Id</code> where I would like to see <code>SELECT * FROM foo WHERE Id = 5</code>. How do I do that?</p>
  
  <pre><code>    DbCommand dbCommand = dbFactory.CreateCommand();
      dbCommand.CommandText = "SELECT * FROM foo WHERE Id = @Id";
  
      DbParameter param = dbCommand.CreateParameter();
      param.ParameterName = "@Id";
      param.Value = 5;
  
      dbCommand.Parameters.Add(param);
  
      dbConnection.Open();
      Log.AddVerbose(String.Format("SQL query: {0}", dbCommand.CommandText));
      dbCommand.ExecuteReader();
  </code></pre>