带有 Simple.Data 的迷你分析器
是否可以将 Mini-Profiler 与 Simple.Data Library 一起使用?我用它从 MySql 获取数据,如下所示:
var db = Database.OpenConnection(ConnectionString);
var book = db.Books.FindById(id);
How can I user Profiler with this code?
Is it possible to use Mini-Profiler with Simple.Data Library? I use it to get data from MySql like this:
var db = Database.OpenConnection(ConnectionString);
var book = db.Books.FindById(id);
How can I user Profiler with this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以告诉 Simple.Data 使用预先存在的连接并使用配置文件连接包装您的连接:
You can tell Simple.Data to use a pre-existing connections and wrap your connection with a profiled connection:
添加到
Simple.Data 可以更好地与 MiniProfiler 集成。
AdoAdapter.ConnectionCreated += (o, args) => args.OverrideConnection(new ProfiledDbConnection((DbConnection)args.Connection, MiniProfiler.Current));
此 basicallt 允许您连接到连接创建事件并使用您自己的分析连接覆盖它。
注意:在撰写本文时,此更改尚未包含在 nuget 包中。因此您需要自定义构建
Simple.Data
There is a new hook that was added to
Simple.Data
which allows for better integration with MiniProfiler.AdoAdapter.ConnectionCreated += (o, args) => args.OverrideConnection(new ProfiledDbConnection((DbConnection)args.Connection, MiniProfiler.Current));
This basicallt allows you to hookup to the connection created event and override it with your own profiled connection.
NOTE: As of writing of this post, this change isn't in the nuget package yet. so you need your custom build of
Simple.Data