DbCommand & Parameters: Get the actual executable SQL (parameter values โ€‹โ€‹are full)

Using a .NET DbCommand object (e.g. OracleCommand, SqlCommand, ODBCCommand, etc.) with parameters, how can I get the SQL that will actually be executed, i.e. with filled parameter values? I could, of course, write my own search / replace method, but this is incredibly close to simply rewriting the parameter logic. (In particular, I would have to consider the type of parameter, parameter names displayed in nonparametric locations, etc.). Anyway, I'm looking for a built-in way to do this, if any.

+4
source share
1 answer

As far as I know, what you want is impossible. The query is sent to the database as a parametric query along with the parameters. Thus, ADO.NET does not know the "finished" SQL that you dream of.

+5
source

Source: https://habr.com/ru/post/1286160/


All Articles