-1

Looking for a way to get the exact query which is sent to SQL Server after substituting literals / parameters.

Executed code:

result = connection.Query(Of MyList)(query, New With {Key .A = A, Key .B = B, Key .C = C})

I would like to capture (in the code, not at the database server side) exact query where parameters @A, @B and @C are already substituted with its values.

Megrez7
  • 1,423
  • 1
  • 15
  • 35
  • You can log the query as explained [here](https://stackoverflow.com/a/50875558/5779732). It is for Dapper Extensions; but same is applicable for Dapper without change. – Amit Joshi Sep 18 '20 at 07:01

2 Answers2

1

Dapper doesn't provide such a capability. You will have to fork its source code and add this sort of logging yourself.

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
1

where parameters @A, @B and @C are already substituted with its values.

Parameters aren't substituted. The query with the parameter markers is the exact query sent to the server. The parameter values are sent separately.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67