Skip to content

Commit 684fb2d

Browse files
committed
Added missing null check
1 parent d451dd3 commit 684fb2d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Output/AdditionalColumnDataGenerator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ public KeyValuePair<string, object> GetAdditionalColumnNameAndValue(SqlColumn ad
2828
: _columnHierarchicalPropertyValueResolver.GetPropertyValueForColumn(additionalColumn, properties);
2929

3030
var columnName = additionalColumn.ColumnName;
31+
if (property.Value == null)
32+
{
33+
return new KeyValuePair<string, object>(columnName, DBNull.Value);
34+
}
35+
3136
if (!(property.Value is ScalarValue scalarValue))
3237
{
3338
return new KeyValuePair<string, object>(columnName, property.Value.ToString());
3439
}
3540

36-
if (scalarValue.Value == null && additionalColumn.AllowNull)
41+
if (scalarValue.Value == null)
3742
{
3843
return new KeyValuePair<string, object>(columnName, DBNull.Value);
3944
}

0 commit comments

Comments
 (0)