SQLite error when accessing first element in table using LINQ

拈花ヽ惹草 提交于 2019-12-05 21:25:12

Calling the .First() method generates a SQL query using the SELECT TOP command, which isn't compatible with SQLite. The solution is to avoid using the .First() method, or to use a library which supports LINQ queries to SQLITE, such as DbLinq or LinqConnect.

As tdr's answer as mentions .First() generates incorrect SQL and can't be used. I've had to convert the results to a list and then use .First() on the list as a workaround. It won't be very efficient if the results are very large though:

var item = featureTable.ToList().First();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!