File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ public class ColumnOptions
17
17
/// </summary>
18
18
public ColumnOptions ( )
19
19
{
20
+ Id = new IdColumnOptions ( ) ;
21
+
20
22
Level = new LevelColumnOptions ( ) ;
21
23
22
24
Properties = new PropertiesColumnOptions ( ) ;
@@ -64,6 +66,11 @@ public ICollection<StandardColumn> Store
64
66
/// </summary>
65
67
public ICollection < DataColumn > AdditionalDataColumns { get ; set ; }
66
68
69
+ /// <summary>
70
+ /// Options for the Id column.
71
+ /// </summary>
72
+ public IdColumnOptions Id { get ; private set ; }
73
+
67
74
/// <summary>
68
75
/// Options for the Level column.
69
76
/// </summary>
@@ -84,6 +91,17 @@ public ICollection<StandardColumn> Store
84
91
/// </summary>
85
92
public LogEventColumnOptions LogEvent { get ; private set ; }
86
93
94
+ /// <summary>
95
+ /// Options for the Id column.
96
+ /// </summary>
97
+ public class IdColumnOptions
98
+ {
99
+ /// <summary>
100
+ /// The name of the Id column. "Id" is used if not set.
101
+ /// </summary>
102
+ public string ColumnName { get ; set ; }
103
+ }
104
+
87
105
/// <summary>
88
106
/// Options for the Level column.
89
107
/// </summary>
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ DataTable CreateDataTable()
163
163
var id = new DataColumn
164
164
{
165
165
DataType = Type . GetType ( "System.Int32" ) ,
166
- ColumnName = "Id" ,
166
+ ColumnName = ! string . IsNullOrWhiteSpace ( _columnOptions . Id . ColumnName ) ? _columnOptions . Id . ColumnName : "Id" ,
167
167
AutoIncrement = true
168
168
} ;
169
169
eventsTable . Columns . Add ( id ) ;
You can’t perform that action at this time.
0 commit comments