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?
Satyaprakash SamantarayPosted Nov 21, 2023, 8:36 AM
There is null handling case is written. Suggest to use ?? operator that will be translated to COALESCE whenever there is a error that the generated SQL query returns an unexpected null value
You can try the below code and do changes on code as per ur requirement.
Garima BansalPosted Nov 21, 2023, 9:21 AM
Satyaprakash Samantaray thank you soo much, it works