sqlite - 如何在 Xamarin Studio 中查看 SQLite.NET PCL 生成的 SQL?

标签 sqlite xamarin xamarin.forms xamarin-studio sqlite-net

我对此进行了研究,我能找到的只是一个打开 .Trace = true 的建议,如下所示:

        db1 = DependencyService.Get<ISQLite>().GetConnection();
        db1.Trace = true;

我也试过这个:

 db2.Trace = true;
 var categories = db2.Query<Category>("SELECT * FROM Category ORDER BY Name").ToList();
 Debug.WriteLine("xxxx");

我这样做了,然后重新启动了应用程序。当我查看应用程序输出时,我只看到有关已启动线程和 xxxx 的信息,但看不到任何 SQL 跟踪信息。

谁能给我这方面的建议。谢谢

最佳答案

您需要在 SQLiteConnection 上设置 TraceTracer(操作)属性以将查询打印到输出:

db.Tracer = new Action<string>(q => Debug.WriteLine(q));
db.Trace = true;

关于sqlite - 如何在 Xamarin Studio 中查看 SQLite.NET PCL 生成的 SQL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40199257/

相关文章:

c# - 在 Entity Framework Core 上转换为 ulong 的 SqlLite 中正确的 RowVersion 模拟

android - 从文件插入 SQLite 数据库,只插入一行

java - 没有这样的表(代码 1)

c# - 将 HttpClient 转换为 RestSharp

android - 防止 Android WebView 在 Xamarin 环境中重新加载页面旋转

xamarin - 可以将 native android 中的任何代码转换为 xamarin.android 吗?

google-maps - xamarin.forms map 隐藏缩放按钮 (+-)

xamarin - 从 OnResume() 导航到默认页面

javascript - expo sqlite 使用现有数据库

ios - Xamarin Forms iOS 启动屏幕图像位置