File tree Expand file tree Collapse file tree 4 files changed +45
-3
lines changed
MappingByCode/IntegrationTests/NH3140
NHibernate/Mapping/ByCode/Impl Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+
4
+ namespace NHibernate . Test . MappingByCode . IntegrationTests . NH3140
5
+ {
6
+ public class Foo
7
+ {
8
+ public virtual Guid Id { get ; set ; }
9
+ public virtual ICollection < Bar > Bars { get ; set ; }
10
+ }
11
+
12
+ public class Bar
13
+ {
14
+ public virtual Guid Id { get ; set ; }
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ using System . Linq ;
2
+ using NHibernate . Cfg . MappingSchema ;
3
+ using NHibernate . Mapping . ByCode ;
4
+ using NUnit . Framework ;
5
+
6
+ namespace NHibernate . Test . MappingByCode . IntegrationTests . NH3140
7
+ {
8
+ public class Fixture
9
+ {
10
+ [ TestCase ( "DifferentFromBar" ) ]
11
+ [ TestCase ( "Bar" ) ]
12
+ public void ExplicitColumnNameIsAlwaysMapped ( string columnName )
13
+ {
14
+ var mapper = new ModelMapper ( ) ;
15
+ mapper . Class < Foo > ( cm => cm . Bag ( x => x . Bars ,
16
+ bpm => { } ,
17
+ cer => cer . ManyToMany ( mtmm => mtmm . Column ( columnName ) ) ) ) ;
18
+ var mapping = mapper . CompileMappingFor ( new [ ] { typeof ( Foo ) , typeof ( Bar ) } ) ;
19
+ var hbmClass = mapping . RootClasses . Single ( x => x . Name == "Foo" ) ;
20
+ var hbmBag = hbmClass . Properties . OfType < HbmBag > ( ) . Single ( ) ;
21
+ var hbmManyToMany = ( HbmManyToMany ) hbmBag . ElementRelationship ;
22
+ Assert . AreEqual ( columnName , hbmManyToMany . column ) ;
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change 673
673
<Compile Include =" NHSpecificTest\NH2923\Models.cs" />
674
674
<Compile Include =" NHSpecificTest\NH2923\ExtraLazyFixture.cs" />
675
675
<Compile Include =" NHSpecificTest\NH3405\Fixture.cs" />
676
+ <Compile Include =" MappingByCode\IntegrationTests\NH3140\Domain.cs" />
677
+ <Compile Include =" MappingByCode\IntegrationTests\NH3140\Fixture.cs" />
676
678
<Compile Include =" NHSpecificTest\NH3428\Entity.cs" />
677
679
<Compile Include =" NHSpecificTest\NH3428\Fixture.cs" />
678
680
<Compile Include =" NHSpecificTest\NH3408\Fixture.cs" />
Original file line number Diff line number Diff line change @@ -44,16 +44,15 @@ public void Column(Action<IColumnMapper> columnMapper)
44
44
unique = manyToMany . unique ,
45
45
uniqueSpecified = manyToMany . unique ,
46
46
} ;
47
- string defaultColumnName = elementType . Name ;
48
- columnMapper ( new ColumnMapper ( hbm , defaultColumnName ) ) ;
47
+ columnMapper ( new ColumnMapper ( hbm , Collection . DefaultElementColumnName ) ) ;
49
48
if ( ColumnTagIsRequired ( hbm ) )
50
49
{
51
50
manyToMany . Items = new [ ] { hbm } ;
52
51
ResetColumnPlainValues ( ) ;
53
52
}
54
53
else
55
54
{
56
- manyToMany . column = defaultColumnName == null || ! defaultColumnName . Equals ( hbm . name ) ? hbm . name : null ;
55
+ manyToMany . column = Collection . DefaultElementColumnName . Equals ( hbm . name ) ? null : hbm . name ;
57
56
manyToMany . unique = hbm . unique ;
58
57
}
59
58
}
You can’t perform that action at this time.
0 commit comments