File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
FluentNHibernate.Testing/FluentInterfaceTests Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,18 @@ public void CanDeclareColumnNullable()
44
44
ElementMapping elementMapping = ( ( IElementMappingProvider ) part ) . GetElementMapping ( ) ;
45
45
var columnMappings = elementMapping . Columns . ToList ( ) ;
46
46
columnMappings . First ( ) . Nullable . ShouldEqual ( true ) ;
47
-
47
+ }
48
+
49
+ [ Test ]
50
+ public void CanDeclareColumnNotNullable ( )
51
+ {
52
+ var part = new ElementPart ( typeof ( MappedObject ) ) ;
53
+ part . Column ( "nullabilityCheck" ) ;
54
+ part . Not . Nullable ( ) ;
55
+
56
+ ElementMapping elementMapping = ( ( IElementMappingProvider ) part ) . GetElementMapping ( ) ;
57
+ var columnMappings = elementMapping . Columns . ToList ( ) ;
58
+ columnMappings . First ( ) . Nullable . ShouldEqual ( false ) ;
48
59
}
49
60
}
50
61
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Diagnostics ;
2
3
using FluentNHibernate . Mapping . Providers ;
3
4
using FluentNHibernate . MappingModel ;
4
5
using FluentNHibernate . MappingModel . Collections ;
@@ -11,6 +12,7 @@ public class ElementPart : IElementMappingProvider
11
12
readonly AttributeStore attributes = new AttributeStore ( ) ;
12
13
readonly AttributeStore columnAttributes = new AttributeStore ( ) ;
13
14
readonly ColumnMappingCollection < ElementPart > columns ;
15
+ bool nextBool = true ;
14
16
15
17
public ElementPart ( Type entity )
16
18
{
@@ -71,14 +73,30 @@ public ElementPart Formula(string formula)
71
73
/// </summary>
72
74
public ElementPart Nullable ( )
73
75
{
74
- columnAttributes . Set ( "NotNull" , Layer . UserSupplied , false ) ;
76
+ columnAttributes . Set ( "NotNull" , Layer . UserSupplied , ! nextBool ) ;
77
+ nextBool = true ;
75
78
return this ;
76
79
}
77
80
81
+ /// <summary>
82
+ /// Inverts the next boolean operation
83
+ /// </summary>
84
+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
85
+ public ElementPart Not
86
+ {
87
+ get
88
+ {
89
+ nextBool = ! nextBool ;
90
+ return this ;
91
+ }
92
+ }
93
+
78
94
ElementMapping IElementMappingProvider . GetElementMapping ( )
79
95
{
80
- var mapping = new ElementMapping ( attributes . Clone ( ) ) ;
81
- mapping . ContainingEntityType = entity ;
96
+ var mapping = new ElementMapping ( attributes . Clone ( ) )
97
+ {
98
+ ContainingEntityType = entity
99
+ } ;
82
100
83
101
foreach ( var column in Columns )
84
102
{
You can’t perform that action at this time.
0 commit comments