【发布时间】:2020-04-28 20:41:57
【问题描述】:
我正在尝试使用 .Net Core API 和 Entity Framework 存储 gps 值、经度和纬度。
这是表格,有一些记录:
这是模型
public class Destinos
{
[Key]
public int idDestino { get; set; }
public String nombreDestino { get; set; }
public String direccionDestino { get; set; }
public float longitudDestino { get; set; }
public float latitudDestino { get; set; }
public String referenciaDestino { get; set; }
}
运行此代码时:
[HttpGet]
public IEnumerable<Destinos> GettDestinos()
{
return _context.tDestinos;
}
我得到了这个异常
你们有什么线索或解决方法吗?
【问题讨论】:
-
因为您在数据库中允许空值,请尝试在您的
Destinos类中将浮点数设为float?或double? -
我刚刚尝试过 double 并且它有效!非常感谢!
标签: sql-server visual-studio entity-framework asp.net-core