We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e15082f commit bea8467Copy full SHA for bea8467
1 file changed
src/OpenPerpetuum.Core.DataServices/Database/ResultSet.cs
@@ -71,9 +71,12 @@ public void AddData(int rowNumber, DataRowObject dataRow)
71
72
private TResultObject ParseScalarResult(object value)
73
{
74
- TResultObject resultObject = (TResultObject)Convert.ChangeType(value, typeof(TResultObject));
+ object tempVal = value == DBNull.Value ? null : value;
75
+ Type resultType = Nullable.GetUnderlyingType(typeof(TResultObject)) ?? typeof(TResultObject);
76
- return resultObject;
77
+ object safeObject = (tempVal == null) ? null : Convert.ChangeType(tempVal, resultType);
78
+
79
+ return (TResultObject)safeObject;
80
}
81
82
private TResultObject ParseObjectResult<TDataObject>(DataRowObject dataRow)
0 commit comments