简体   繁体   English

如何在实体框架中存储特定的浮点数

[英]How to store a specific float in Entity FrameWork

I am trying to follow a guide from Google on how to store location data ( here ), but, I need to convert this to ASP.NET MVC C# and having a little trouble setting up the class. 我正在尝试遵循Google的有关如何存储位置数据的指南( 此处 ),但是,我需要将其转换为ASP.NET MVC C#,并且在设置类时遇到了一些麻烦。

I have just read this question , and, I think it is similar, but, I can't really understand the solution. 我刚刚阅读了这个问题 ,并且我认为它很相似,但是我无法真正理解该解决方案。

I was wondering if anyone can help me on how to store a [10,6] float in the an Entity Framework Code First Generated database, or, a better way of storing longitude and latitude in EF. 我想知道是否有人可以帮助我如何在实体框架代码优先生成的数据库中存储[10,6]浮点数,或者在EF中存储经度和纬度的更好方法。

Can't you just use decimal instead of float ? 您不能只使用decimal代替float吗? I think the range and precision will be enough. 我认为范围和精度就足够了。

You can always create a decimal property for storing and a float property that will use the other one and do the conversion if you need float in the rest of your app. 你总是可以创建一个decimal用于存储属性和float将使用另一种和做转换,如果你需要财产float在你的应用程序的其余部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM