File tree Expand file tree Collapse file tree 6 files changed +48
-2
lines changed
Fixtures/AutoMappingAlterations
FluentNHibernate/Automapping/Alterations Expand file tree Collapse file tree 6 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -40,5 +40,17 @@ public void RegularAutoMappingsStillWorkWhenOverridesApplied()
40
40
new AutoMappingTester < Baz > ( model )
41
41
. Element ( "class/property[@name='Name']" ) . Exists ( ) ;
42
42
}
43
+
44
+ [ Test ]
45
+ public void OverridesCanBeAbstract ( )
46
+ {
47
+ var model = AutoMap . AssemblyOf < Qux > ( )
48
+ . Where ( t => t . Namespace == typeof ( Qux ) . Namespace ) ;
49
+
50
+ alteration . Alter ( model ) ;
51
+
52
+ new AutoMappingTester < Qux > ( model )
53
+ . Element ( "class" ) . HasAttribute ( "batch-size" , "10" ) ;
54
+ }
43
55
}
44
56
}
Original file line number Diff line number Diff line change
1
+ using FluentNHibernate . Automapping ;
2
+ using FluentNHibernate . Automapping . Alterations ;
3
+
4
+ namespace FluentNHibernate . Testing . Fixtures . AutoMappingAlterations
5
+ {
6
+ public abstract class AbstractOveride < T > : IAutoMappingOverride < T >
7
+ {
8
+ public void Override ( AutoMapping < T > mapping )
9
+ {
10
+ mapping . BatchSize ( 10 ) ;
11
+ }
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ using FluentNHibernate . Testing . Fixtures . AutoMappingAlterations . Model ;
2
+
3
+ namespace FluentNHibernate . Testing . Fixtures . AutoMappingAlterations
4
+ {
5
+ public class AbstractOverrideImplementation : AbstractOveride < Qux >
6
+ {
7
+
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ namespace FluentNHibernate . Testing . Fixtures . AutoMappingAlterations . Model
2
+ {
3
+ public class Qux
4
+ {
5
+ public virtual int Id { get ; set ; }
6
+ public virtual string Name { get ; set ; }
7
+ }
8
+ }
Original file line number Diff line number Diff line change 120
120
<Compile Include =" AutoMapping\Overrides\ClassMappingOverrides.cs" />
121
121
<Compile Include =" AutoMapping\Overrides\CompositeIdOverrides.cs" />
122
122
<Compile Include =" AutoMapping\Overrides\HibernateMappingOverrides.cs" />
123
- <Compile Include =" AutoMapping\Overrides\ParentOverridesWithSubclasses.cs" />
123
+ <Compile Include =" AutoMapping\Overrides\ParentOverridesWithSubclasses.cs" />
124
124
<Compile Include =" AutoMapping\UnionSubclassConventionTests.cs" />
125
- <Compile Include =" AutoMapping\UnionSubclassTests.cs" />
125
+ <Compile Include =" AutoMapping\UnionSubclassTests.cs" />
126
+ <Compile Include =" Fixtures\AutoMappingAlterations\AbstractOverride.cs" />
127
+ <Compile Include =" Fixtures\AutoMappingAlterations\AbstractOverrideImplementation.cs" />
128
+ <Compile Include =" Fixtures\AutoMappingAlterations\Model\Qux.cs" />
126
129
<Compile Include =" StubTypeSource.cs" />
127
130
<Compile Include =" AutoMapping\TestFixtures.cs" />
128
131
<Compile Include =" Cfg\Db\DB2ConfigurationTester.cs" />
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public void Alter(AutoPersistenceModel model)
34
34
{
35
35
// find all types deriving from IAutoMappingOverride<T>
36
36
var types = from type in assembly . GetExportedTypes ( )
37
+ where ! type . IsAbstract
37
38
let entity = ( from interfaceType in type . GetInterfaces ( )
38
39
where interfaceType . IsGenericType && interfaceType . GetGenericTypeDefinition ( ) == typeof ( IAutoMappingOverride < > )
39
40
select interfaceType . GetGenericArguments ( ) [ 0 ] ) . FirstOrDefault ( )
You can’t perform that action at this time.
0 commit comments