albert albert

albert albert

  • NA
  • 524
  • 0

Null value

Jul 8 2014 6:55 AM
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)