src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerSinkTraits.cs
/// <summary>
///     Mapping values from properties which have a corresponding data row.
///     Matching is done based on Column name and property key
///     Standard columns are not mapped
/// </summary>        
/// <param name="properties"></param>
Mapping values from properties which have a corresponding data row.
Matching is done based on Column name and property key
Standard columns are not mapped
Mapping values from properties which have a corresponding data row . Matching is done based on Column name and property key Standard columns are not mapped
private IEnumerable<KeyValuePair<string, object>> ConvertPropertiesToColumn(IReadOnlyDictionary<string, LogEventPropertyValue> properties)
        {
            foreach (var property in properties)
            {
                if (!EventTable.Columns.Contains(property.Key) || StandardColumnNames.Contains(property.Key))
                    continue;
                var columnName = property.Key;
                var columnType = EventTable.Columns[columnName].DataType;
                if (!(property.Value is ScalarValue scalarValue))
                {
                    yield return new KeyValuePair<string, object>(columnName, property.Value.ToString());
                    continue;
                }
                if (scalarValue.Value == null && EventTable.Columns[columnName].AllowDBNull)
                {
                    yield return new KeyValuePair<string, object>(columnName, DBNull.Value);
                    continue;
                }
                if (TryChangeType(scalarValue.Value, columnType, out var conversion))
                {
                    yield return new KeyValuePair<string, object>(columnName, conversion);
                }
                else
                {
                    yield return new KeyValuePair<string, object>(columnName, property.Value.ToString());
                }
            }
        }
private IEnumerable < KeyValuePair < string , object > > ConvertPropertiesToColumn ( IReadOnlyDictionary < string , LogEventPropertyValue > properties ) { foreach ( var property in properties ) { if ( ! EventTable . Columns . Contains ( property . Key ) || StandardColumnNames . Contains ( property . Key ) ) continue ; var columnName = property . Key ; var columnType = EventTable . Columns [ columnName ] . DataType ; if ( ! ( property . Value is ScalarValue scalarValue ) ) { yield return new KeyValuePair < string , object > ( columnName , property . Value . ToString ( ) ) ; continue ; } if ( scalarValue . Value == null && EventTable . Columns [ columnName ] . AllowDBNull ) { yield return new KeyValuePair < string , object > ( columnName , DBNull . Value ) ; continue ; } if ( TryChangeType ( scalarValue . Value , columnType , out var conversion ) ) { yield return new KeyValuePair < string , object > ( columnName , conversion ) ; } else { yield return new KeyValuePair < string , object > ( columnName , property . Value . ToString ( ) ) ; } } }
Mapping values from properties which have a corresponding data row.
Mapping values from properties which have a corresponding data row .
properties
IReadOnlyDictionary<string, LogEventPropertyValue>
None