我研究了这个问题,我能找到的就是这样打开.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跟踪信息。
接下来我可以尝试什么?
3条答案
按热度按时间7z5jn7bk1#
您需要在
SQLiteConnection
上设置Trace
和Tracer
(action)属性,以将查询打印到输出:hiz5n14c2#
在
Application Output
窗口中查找以**Executing
**开头的行将
Trace
设置为true后的输出示例:参考:https://github.com/praeclarum/sqlite-net/blob/38a5ae07c886d6f62cecd8fdeb8910d9b5a77546/src/SQLite.cs
wfypjpf43#
SQLite PCL使用Debug.WriteLine,这意味着日志仅包含在PCL的Debug构建中。
删除对sqlite.net PCL的nuget引用(保留原生引用),并将SQLite.cs作为类添加到项目中,然后执行调试构建,并设置Trace标志,您将看到跟踪。
除了在Xamarin iOS项目中包含SQLite.cs文件外,我不需要做任何特殊的事情就可以做到这一点:
输出: