我在 WherOnEarth 应用程序中做了类似的事情。我们有一个 SQLCE 数据库,我们将数据存储在其中,然后加载附近的内容。
背景阅读:http ://www.silverlightshow.net/items/Windows-Phone-7.1-Local-SQL-Database.aspx & http://www.jeffblankenburg.com/2011/11/30/31-days-of -mango-day-30-本地数据库/
我有一个随应用程序提供的 sdf 文件,如下所示的数据类
[Table]
public class PointData : IPositionElement, INotifyPropertyChanged
{
[Column]
public string Description { get; set; }
[Column]
public double Latitude { get; set; }
[Column]
public double Longitude { get; set; }
然后,我们阅读了附近的要点,并通过以下方式获得了它们:
(from ht in _context.Points
where ht.Latitude >= bottomLeft.Latitude && ht.Latitude <= topRight.Latitude &&
ht.Longitude >= bottomLeft.Longitude && ht.Longitude <= topRight.Longitude
select ht
).ToArray();
这种方法对我来说足够快(即,从 sdf 文件中取出项目所用的时间比将它们放置在屏幕上所需的时间要少,并与此相关的所有其他相关数学运算。诚然,我并没有试图从中获取 300000 个项目数据库。关于索引和类似的事情,我可以做更多的优化,但正如我所说,它现在已经足够快了,所以我稍后会重新审视它。