@@ -123,5 +123,69 @@ public void WritesLogEventWithCustomNamedProperties()
123
123
VerifyStringColumnWritten ( additionalColumn1Name , property1Value ) ;
124
124
VerifyIntegerColumnWritten ( additionalColumn2Name , property2Value ) ;
125
125
}
126
+
127
+ [ Fact ]
128
+ public void WritesLogEventWithColumnsFromHierarchicalNamedProperties ( )
129
+ {
130
+ // Arrange
131
+ const string additionalColumn1Name = "AdditionalColumn1" ;
132
+ const string additionalProperty1Name = "AdditionalProperty1.SubProperty1" ;
133
+ const string additionalColumn2Name = "AdditionalColumn2" ;
134
+ const string additionalProperty2Name = "AdditionalProperty2.SubProperty2.SubSubProperty1" ;
135
+ var columnOptions = new MSSqlServer . ColumnOptions
136
+ {
137
+ AdditionalColumns = new List < SqlColumn >
138
+ {
139
+ new SqlColumn
140
+ {
141
+ ColumnName = additionalColumn1Name ,
142
+ PropertyName = additionalProperty1Name ,
143
+ DataType = SqlDbType . NVarChar ,
144
+ AllowNull = true ,
145
+ DataLength = 100
146
+ } ,
147
+ new SqlColumn
148
+ {
149
+ ColumnName = additionalColumn2Name ,
150
+ PropertyName = additionalProperty2Name ,
151
+ DataType = SqlDbType . Int ,
152
+ AllowNull = true
153
+ }
154
+ }
155
+ } ;
156
+ var property1Value = "PropertyValue1" ;
157
+ var property2Value = 2 ;
158
+
159
+ // Act
160
+ Log . Logger = new LoggerConfiguration ( )
161
+ . WriteTo . MSSqlServer (
162
+ DatabaseFixture . LogEventsConnectionString ,
163
+ sinkOptions : new MSSqlServerSinkOptions
164
+ {
165
+ TableName = DatabaseFixture . LogTableName ,
166
+ AutoCreateSqlTable = true
167
+ } ,
168
+ columnOptions : columnOptions ,
169
+ formatProvider : CultureInfo . InvariantCulture )
170
+ . CreateLogger ( ) ;
171
+ Log . Information ( "Hello {@AdditionalProperty1} from thread {@AdditionalProperty2}" ,
172
+ new StructuredType
173
+ {
174
+ SubProperty1 = property1Value
175
+ } ,
176
+ new StructuredType
177
+ {
178
+ SubProperty2 = new StructuredSubType
179
+ {
180
+ SubSubProperty1 = property2Value
181
+ }
182
+ } ) ;
183
+ Log . CloseAndFlush ( ) ;
184
+
185
+ // Assert
186
+ VerifyDatabaseColumnsWereCreated ( columnOptions . AdditionalColumns ) ;
187
+ VerifyStringColumnWritten ( additionalColumn1Name , property1Value ) ;
188
+ VerifyIntegerColumnWritten ( additionalColumn2Name , property2Value ) ;
189
+ }
126
190
}
127
191
}
0 commit comments