0
我想用Xamarin上的SQLite.NET软件包进行查询。无法获取SQL:减
public static List<Place> searchForPlace(double lat, double lng)
{
var query = conn.Table<GPSPoint>().Where(v => Math.Sqrt(Math.Pow(v.lat - lat, 2) - Math.Pow(v.lng - lng, 2)) < 5);
List<Place> l = new List<Place>();
foreach (var gpsPoint in query) // the foreach statement causes the error System.NotSupportedException: Cannot get SQL for: Subtract
{
var queryPlaces = conn.Table<Place>().Where(v => v.ID == gpsPoint.ID);
foreach (var place in queryPlaces)
l.Add(place);
break;
}
return l;
}
但我的代码给我这个错误System.NotSupportedException: Cannot get SQL for: Subtract
。
这是我使用的初始化数据库
public DatabaseConnection()
{
string folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
conn = new SQLiteConnection(System.IO.Path.Combine(folder, "navigationApp.db"));
conn.CreateTable<GPSPoint>();
conn.CreateTable<Place>();
}
有什么问题,我怎么能解决它的代码?
你的代码,使我的错误'TableQuery不包含“ToList”,没有扩展方法“ToList”接受一个类型的第一个参数“TableQuery ”的定义可以found' –
您需要调用ToList()'带有一个泛型参数,我猜。 'ToList()'; –
我根本无法调用'ToList'方法。 [这种方法没有定义](http://imgur.com/LAMZAgp)。 –