本文介绍了Linq将String比较为Double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个LINQ查询,该查询接受一个字符串值列表(包含数字)并检查 maxLon (一个Double变量)



示例:

How to create a LINQ query that takes a list of string values (that has numbers) and check it against a maxLon (a Double variable)

Example:

Locquery = (DataServiceQuery<ava_location>)(from c in ctx.ava_locationSet
                                            where (Double.Parse(c.fn_Longitude) <= maxLon)
                                            Select new ava_location
                                            {
                                               fn_Latitude = c.fn_Latitude,
                                               fn_Longitude = c.fn_Longitude,
                                            }).Skip(0).Take(MaxRows);





这个编译,但在执行时,我得到以下异常:



This compiles, but upon execution, I got the following exception:

System.NotSupportedException was unhandled by user code
  Message=The expression ((((Parse([10007].fn_Latitude) >= 24.7614342656583) And (Parse([10007].fn_Latitude) <= 24.7686757343417)) And (Parse([10007].fn_Longitude) >= -80.0667877343417)) And (Parse([10007].fn_Longitude) <= -80.0595462656583)) is not supported.





如何使用数字的字符串值来大于或小于?



How can I use a string value of numbers to do greater than, or less than?

推荐答案


这篇关于Linq将String比较为Double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 12:45