@@ -274,4 +274,66 @@ private class Component
274
274
public string Property { get ; set ; }
275
275
}
276
276
}
277
+
278
+ public class when_compiling_the_mappings_with_multiple_nested_component_mappings
279
+ {
280
+ Establish context = ( ) => {
281
+ var component_map = new ComponentMap < Component > ( ) ;
282
+ component_map . Component ( x => x . NestedComponent1 ,
283
+ c => c . Map ( y => y . Property , "PROP1" ) ) ;
284
+ component_map . Component ( x => x . NestedComponent2 ,
285
+ c => c . Map ( y => y . Property , "PROP2" ) ) ;
286
+
287
+ var class_map = new ClassMap < Target > ( ) ;
288
+ class_map . Id ( x => x . Id ) ;
289
+ class_map . Component ( x => x . Component )
290
+ . ColumnPrefix ( "A_" ) ;
291
+
292
+ persistence_model = new FluentNHibernate . PersistenceModel ( ) ;
293
+ persistence_model . Add ( class_map ) ;
294
+ persistence_model . Add ( component_map ) ;
295
+ } ;
296
+
297
+ Because of = ( ) => {
298
+ mappings = persistence_model . BuildMappings ( ) ;
299
+ class_mapping = mappings . SelectMany ( x => x . Classes ) . First ( ) ;
300
+ } ;
301
+
302
+ It should_use_the_column_prefix_for_all_nested_component_columns = ( ) => {
303
+ var root_component = class_mapping . Components . First ( x => x . Name == "Component" ) ;
304
+
305
+ root_component
306
+ . Components . First ( x => x . Name == "NestedComponent1" )
307
+ . Properties . SelectMany ( x => x . Columns )
308
+ . Select ( x => x . Name )
309
+ . ShouldContain ( "A_PROP1" ) ;
310
+
311
+ root_component
312
+ . Components . First ( x => x . Name == "NestedComponent2" )
313
+ . Properties . SelectMany ( x => x . Columns )
314
+ . Select ( x => x . Name )
315
+ . ShouldContain ( "A_PROP2" ) ;
316
+ } ;
317
+
318
+ private static FluentNHibernate . PersistenceModel persistence_model ;
319
+ private static IEnumerable < HibernateMapping > mappings ;
320
+ private static ClassMapping class_mapping ;
321
+
322
+ private class Target
323
+ {
324
+ public int Id { get ; set ; }
325
+ public Component Component { get ; set ; }
326
+ }
327
+
328
+ private class Component
329
+ {
330
+ public NestedComponent NestedComponent1 { get ; set ; }
331
+ public NestedComponent NestedComponent2 { get ; set ; }
332
+ }
333
+
334
+ private class NestedComponent
335
+ {
336
+ public string Property { get ; set ; }
337
+ }
338
+ }
277
339
}
0 commit comments