@@ -35,6 +35,7 @@ internal sealed class MSSqlServerSinkTraits : IDisposable
35
35
public JsonFormatter JsonFormatter { get ; }
36
36
public ISet < string > AdditionalDataColumnNames { get ; }
37
37
public DataTable EventTable { get ; }
38
+ public List < string > ExcludedColumnNames { get ; }
38
39
39
40
public MSSqlServerSinkTraits ( string connectionString , string tableName , string schemaName , ColumnOptions columnOptions , IFormatProvider formatProvider , bool autoCreateSqlTable )
40
41
{
@@ -50,6 +51,11 @@ public MSSqlServerSinkTraits(string connectionString, string tableName, string s
50
51
ColumnOptions = columnOptions ?? new ColumnOptions ( ) ;
51
52
FormatProvider = formatProvider ;
52
53
54
+ ExcludedColumnNames = new List < string > ( ColumnOptions . Store . Count + 1 ) ;
55
+ ExcludedColumnNames . Add ( "id" ) ;
56
+ foreach ( var column in ColumnOptions . Store )
57
+ ExcludedColumnNames . Add ( column . ToString ( ) ) ;
58
+
53
59
if ( ColumnOptions . AdditionalDataColumns != null )
54
60
AdditionalDataColumnNames = new HashSet < string > ( ColumnOptions . AdditionalDataColumns . Select ( c => c . ColumnName ) , StringComparer . OrdinalIgnoreCase ) ;
55
61
@@ -183,13 +189,14 @@ private string ConvertPropertiesToXmlStructure(IEnumerable<KeyValuePair<string,
183
189
/// <summary>
184
190
/// Mapping values from properties which have a corresponding data row.
185
191
/// Matching is done based on Column name and property key
192
+ /// Standard columns are not mapped
186
193
/// </summary>
187
194
/// <param name="properties"></param>
188
195
private IEnumerable < KeyValuePair < string , object > > ConvertPropertiesToColumn ( IReadOnlyDictionary < string , LogEventPropertyValue > properties )
189
196
{
190
197
foreach ( var property in properties )
191
198
{
192
- if ( ! EventTable . Columns . Contains ( property . Key ) )
199
+ if ( ! EventTable . Columns . Contains ( property . Key ) || ExcludedColumnNames . Contains ( property . Key ) )
193
200
continue ;
194
201
195
202
var columnName = property . Key ;
0 commit comments