Skip to content

Commit 640ae31

Browse files
committed
Merge branch 'anotherPassAt37th' of https://github.com/chester89/fluent-nhibernate into chester89-anotherPassAt37th
2 parents c9d31f7 + e47a6ae commit 640ae31

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/FluentNHibernate.Testing/FluentInterfaceTests/ElementPartTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,18 @@ public void CanSetFormula()
3333
ElementMapping elementMapping = ((IElementMappingProvider)part).GetElementMapping();
3434
elementMapping.Formula.ShouldEqual("formula");
3535
}
36+
37+
[Test]
38+
public void CanDeclareColumnNullable()
39+
{
40+
var part = new ElementPart(typeof(MappedObject));
41+
part.Column("nullabilityCheck");
42+
part.Nullable();
43+
44+
ElementMapping elementMapping = ((IElementMappingProvider)part).GetElementMapping();
45+
var columnMappings = elementMapping.Columns.ToList();
46+
columnMappings.First().Nullable.ShouldEqual(true);
47+
48+
}
3649
}
3750
}

src/FluentNHibernate/Mapping/ElementPart.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ public ElementPart Formula(string formula)
6666
return this;
6767
}
6868

69+
/// <summary>
70+
/// Specify the nullability of the column
71+
/// </summary>
72+
public ElementPart Nullable()
73+
{
74+
columnAttributes.Set("NotNull", Layer.UserSupplied, false);
75+
return this;
76+
}
77+
6978
ElementMapping IElementMappingProvider.GetElementMapping()
7079
{
7180
var mapping = new ElementMapping(attributes.Clone());

src/FluentNHibernate/MappingModel/ColumnMapping.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public bool NotNull
4747
get { return attributes.GetOrDefault<bool>("NotNull"); }
4848
}
4949

50+
public bool Nullable
51+
{
52+
get { return !NotNull; }
53+
}
54+
5055
public bool Unique
5156
{
5257
get { return attributes.GetOrDefault<bool>("Unique"); }

0 commit comments

Comments
 (0)