有沒有辦法從ADO.NET調用中獲取發送到SQL Server的原始文本(如SQL Profiler中所示)?原始SQL從存儲過程調用從.NET發送到SQL Server
using(SqlConnection conn = new SqlConnection(connString)) {
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetSomeData";
cmd.Parameters.Add("@id").Value = someId;
cmd.Parameters.Add("@someOtherParam").Value = "hello";
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
// this sends up the call: exec GetSomeData @id=24, @someOtherParam='hello'
// how can I capture that and write it to debug?
Debug.Write("exec GetSomeData @id=24, @someOtherParam='hello'");
}