2
Answers

Null value

albert albert

albert albert

10y
1.6k
1
Hi everybody,
 
I have this:
 
[code]
 
if (medicijn.Volgorde == 999)
{
int medicijnHigest = medicijnService.GetAll().Where(i => i.Volgorde != 999).Max(m => m.Volgorde);
medicijn.Volgorde = medicijnHigest + 1;
medicijnService.Save(medicijn);
}
[/code] 
 
but I get this error on  medicijnHigest:
 
 
 
An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code
Additional information: 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.
 
Thank you 
 
 
 
Answers (2)