Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 3-Jan-17 21:56pm

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.
 
Share this answer
 
either x.RateTableCategory2.RateCategoryID2 its returns int(other than long) or its return type should be nullable.
 
Share this answer
 
try this

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

or

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900