I ran into a null reference exception on line:
dr["IsSandpit"] = p.MineralName.Equals("Sand");
Of course the fix is:
dr["IsSandpit"] = p.MineralName!=null && p.MineralName.Equals("Sand");
But I am wondering if a nullable type can be configured that the Equals method instead of throwing a null reference exception would just return false
for a strongly typed variable? Or some method NotNullAndEquals
?
Null in the database means something like "not filled" or empty and "empty" surely is not equal to "Sand". (Perhaps this is a duplicate but I have not found the right question)