Reputation: 1147
I've got problems at this line:
int? nextLevel = (from p in cd.Objective
where p.Parent_ObjectiveID == null
select p.ObjectiveID).Max() + 1;
The error specifies:
The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type.
How can I fix it?
UPDATE:
But p.Parent_ObjectiveID is int? datatype. It can be null.
Upvotes: 0
Views: 180
Reputation: 12437
Basically, p.Parent_ObjectiveID cannot be null
, (i.e. a "non-nullable" type). So there is no need to check if it is a null
or not.
So to fix it, get rid of the where
part, or change it from null
, to an System.Int32
value.
Upvotes: 0
Reputation: 1919
The objectiveID is of type which is not nullable. So whats the point of checking it for NULL type? You never can assign a null value to a non nullable value. May be use objectiveID? instead..
Upvotes: 3