将字符串转换为十进制并与 Linq to NHibernate 3.1 进行比较
我有一个像这样的表:
Name Height
------- ---------
Sam "1.80"
Paul "1.79"
Max "1.81m"
Steve "none"
我只想过滤身高 > 的人1.79。 为此,我必须转换为十进制然后进行比较。忽略非数字值,例如“none”。 我尝试了 Decimal.Parse() 和 Convert.ToDecimal() 但显示错误 System.NotSupportedException
peoples = peoples.Where(f => Convert.ToDecimal(f.Height) > 1.8);
peoples = peoples.Where(f => decimal.Parse(f.Height) > 1.8);
有解决方案吗?
Tks[]
帕特里克·科埃略
I have a table like:
Name Height
------- ---------
Sam "1.80"
Paul "1.79"
Max "1.81m"
Steve "none"
I want to filter only the peoples with height > 1.79.
To do this, I must convert to decimal and then compare. Ignoring the values that are not numerical, such as "none".
I tryed Decimal.Parse() and Convert.ToDecimal() but show a error System.NotSupportedException
peoples = peoples.Where(f => Convert.ToDecimal(f.Height) > 1.8);
peoples = peoples.Where(f => decimal.Parse(f.Height) > 1.8);
Any solution??
Tks[]
Patrick Coelho
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 NH.Linq 将数据库中的非数字值与数字进行比较的唯一方法是:
The only way you will be able to compare the non-numeric values in the database against a number using NH.Linq is either: