using Microsoft.Data.SqlClient;
public static void Main()
Console.WriteLine("Hello World");
string commandText = "SELECT * FROM dbo.Files WHERE CustomerID = @ID;";
SqlCommand command = new SqlCommand(commandText);
command.Parameters.AddWithValue("@ID", "mem");
Console.WriteLine(command.CommandText + "\n\n");
private static void LogSQL(SqlCommand cmd)
string query = cmd.CommandText;
foreach (SqlParameter prm in cmd.Parameters)
case System.Data.SqlDbType.Bit:
int boolToInt = (bool)prm.Value ? 1 : 0;
query = query.Replace(prm.ParameterName, string.Format("{0}", (bool)prm.Value ? 1 : 0));
case System.Data.SqlDbType.Int:
query = query.Replace(prm.ParameterName, string.Format("{0}", prm.Value));
case System.Data.SqlDbType.VarChar:
query = query.Replace(prm.ParameterName, string.Format("'{0}'", prm.Value));
query = query.Replace(prm.ParameterName, string.Format("'{0}'", prm.Value));
Console.WriteLine("{0}", query);