如何在linq查询中添加十进制值 [英] How to add decimal values in linq query

查看:74
本文介绍了如何在linq查询中添加十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表中有七个十进制字段,我希望所有值都加起来,如果我像val =(i.val1 + i.val2 + .. i.val7)那样正常添加,则只有在所有字段都是不是null,如果这些字段中的任何一个都显示为null.您能否告诉我该怎么做.

I have seven decimal fields in my table.I want all values sum.If I am adding normally like val = (i.val1+ i.val2+.. i.val7).I am getting the value only if all fields are not null,if any of these fields are the value is displaying as null.can u tell me how to do this.

推荐答案

@Greysontyrus像这样吗?

i.valx是否为nullable?如果是,则val = i.val1? 0 + i.val2 ?? 0 ...依此类推
@Greysontyrus like this?

are the i.valx nullables? if yes then val = i.val1 ?? 0 + i.val2 ?? 0...and so on


这篇关于如何在linq查询中添加十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆