I am developing a project in C# with a SQL Server database.
I want to save some information in the database when a query has any conditions, so my idea was have a generic method that launches the commit of the transaction and, if the commit has the conditions required, saves the information.
My question: is there any way to obtain the SQL code of the transaction just before the .commit()?
For example, something like that:
public void insertInfo(object)
{
using (Context context = new Context())
{
[Do an insert]
[Do a second insert]
[Do an update]
context.Save()
}
}
// In the Context
public void Save()
{
[Here I want to get the SQL statement(s) that will be affected by the "transaction.Commit()"]
transaction.Commit();
}