Garima Bansal

Garima Bansal

  • 1k
  • 694
  • 41.4k

cast to value type 'System.Int32' failed because the materialized

Nov 21 2023 7:43 AM

I have the following code. I'm getting error: 

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

var MaxValue = (from t in context.ppatalukmasters where t.regioncode == model.regioncode select t.talukcode).Max();

 

How can i modify?


Answers (2)