我无法解决问题 [英] I am not able solve the issue

查看:71
本文介绍了我无法解决问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

List<long> key = rateCardData.Select(x => x.RateTableCategory2.RateCategoryID2).ToList();













The cast to value type 'Int64' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.





我尝试过:



我在这行收到错误



What I have tried:

I am getting error in this line

List<long> key = rateCardData.Select(x => x.RateTableCategory2.RateCategoryID2).ToList();





没有得到任何构建错误



not getting any build error

推荐答案

嘿,murkalkiran



您应该检查RateTableCategory2是否为null或者RateTableCategory2.RateCategoryID2是否可以转换为long!该错误看起来像数据源 rateCardData 有一些空值。



它不会导致构建错误,但会导致运行时错误。
hey,murkalkiran

You should check whether RateTableCategory2 is null or whether RateTableCategory2.RateCategoryID2 can cast to long! The error looks like that the datasource rateCardData has some null value.

It won't cause the build errors ,but the runtime errors.


x.RateTableCategory2.RateCategoryID2返回int(除了long)或者它的返回类型应该是可为空的。
either x.RateTableCategory2.RateCategoryID2 its returns int(other than long) or its return type should be nullable.


试试这个



try this

List<long> key = rateCardData.Select(x=>.RateTableCategory2.RateCategoryID2).ToList<long>();








or

List<long> key =(List<long>) rateCardData.Select(x=>.RateTableCategory2.RateCategoryID2).ToList();


这篇关于我无法解决问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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