EF 数据到新的引脚位置

EF data to new pin location

我有一个带有纬度和经度的 SQL 服务器数据库,我已通过 EF 将其导入到我的 WPF C# 应用程序中。

现在,在我的应用程序中,我已经 Bing 导入了地图,我想根据通过 EF 查询获得的数据创建图钉。

private void LoadPins()
{
    var result = (from s in PE.tbl_SafeSpace
                  select new
                         { s.lat, s.@long }).ToList();

    for (int i = 0; i < result.Count; i++)
    {
        Pushpin pin = new Pushpin();
        pin.Location = new Location(result[i]);

        // Adds the pushpin to the map.
        bMaps.Children.Add(pin);
    }    
}  

我知道我在将数据放入该位置时做错了,但我不确定是什么。

一个建议,如果您有错误,请在这里评论,我很乐意更新我的答案。

private void LoadPins()
{
    List<Location> result = (from s in PE.tbl_SafeSpace
                  select new Location
                         { 
                           Latitude = (double)s.lat,                               
                           Longitude =(double)s.long 
                          }).ToList();

    foreach(Location location in result)
    {
        Pushpin pin = new Pushpin();
        pin.Location = location;

        // Adds the pushpin to the map.
        bMaps.Children.Add(pin);
    }    
}