Is there a way to dump the generated sql to the Debug log or something? I'm using it in a winforms solution so the mini-profiler idea won't work for me.
相关问题
- Sql CE Inconsistent with Multiple Statements
- Dapper insert a list?
- Using Dapper with BLOBs and SQL Server CE
- Dapper execute stored procedure raises ArgumentExc
- dapper “IN” clause not working with multiple value
相关文章
- 博客园混用 Dapper 跟 EF 方式?
- Using Dapper-dot-net, how do I map SQL uniqueident
- How can I send a string as NULL to SQLServer using
- Which transaction is better with Dapper: BEGIN TRA
-
TypeHandler
doesn't seem to be called - Can I return a collection of multiple Derived Type
- Dapper Multi Mapping with QueryMultiple
- “MultiLevels” Mapping Dapper using SplitOn
This is not exhaustive and is essentially a bit of hack, but if you have your sql and you want to initialise your parameters it's useful for basic debugging.
You can then just use this in the immediate or watch windows to grab the SQL.
Just to add an update here since I see this question still get's quite a few hits - these days I use either Glimpse or Stackify Prefix which both have sql command trace capabilities.
It's not exactly what I was looking for when I asked the original question but solve the same problem.
I got the same issue and implemented some code after doing some search but having no ready-to-use stuff. There is a package on nuget MiniProfiler.Integrations I would like to share.
Update V2: it supports to work with other database servers, for MySQL it requires to have MiniProfiler.Integrations.MySql
Below are steps to work with SQL Server:
1.Instantiate the connection
2.After all works done, write all commands to a file if you want
Dapper does not currently have an instrumentation point here. This is perhaps due, as you note, to the fact that we (as the authors) use mini-profiler to handle this. However, if it helps, the core parts of mini-profiler are actually designed to be architecture neutral, and I know of other people using it with winforms, wpf, wcf, etc - which would give you access to the profiling / tracing connection wrapper.
In theory, it would be perfectly possible to add some blanket capture-point, but I'm concerned about two things:
null
in most cases) would have much impactOf course, the other thing you could do is: steal the connection wrapper code from mini-profiler, and replace the profiler-context stuff with just:
Debug.WriteLine
etc.