Skip to content

Commit fd5238d

Browse files
committed
Use nullables
1 parent 7a0a873 commit fd5238d

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/NHibernate/SqlTypes/SqlType.cs

+14-17
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ namespace NHibernate.SqlTypes
2323
[Serializable]
2424
public class SqlType : IEquatable<SqlType>
2525
{
26+
private readonly int? _length;
27+
private readonly byte? _precision;
28+
private readonly byte? _scale;
29+
2630
public SqlType(DbType dbType)
2731
{
2832
DbType = dbType;
@@ -31,40 +35,33 @@ public SqlType(DbType dbType)
3135
public SqlType(DbType dbType, int length)
3236
{
3337
DbType = dbType;
34-
Length = length;
35-
LengthDefined = true;
38+
_length = length;
3639
}
3740

3841
public SqlType(DbType dbType, byte precision, byte scale)
3942
{
4043
DbType = dbType;
41-
Precision = precision;
42-
Scale = scale;
43-
ScaleDefined = true;
44-
PrecisionDefined = true;
44+
_precision = precision;
45+
_scale = scale;
4546
}
4647

4748
public SqlType(DbType dbType, byte scale)
4849
{
4950
DbType = dbType;
50-
Scale = scale;
51-
ScaleDefined = true;
51+
_scale = scale;
5252
}
5353

5454
public DbType DbType { get; }
5555

56-
public int Length { get; }
57-
58-
public byte Precision { get; }
59-
60-
public byte Scale { get; }
56+
public int Length => _length.GetValueOrDefault();
57+
public byte Precision => _precision.GetValueOrDefault();
58+
public byte Scale => _scale.GetValueOrDefault();
59+
public bool LengthDefined => _length.HasValue;
6160

62-
public bool LengthDefined { get; }
61+
public bool PrecisionDefined => _precision.HasValue;
6362

64-
public bool PrecisionDefined { get; }
65-
6663

67-
public bool ScaleDefined { get; }
64+
public bool ScaleDefined => _scale.HasValue;
6865

6966
#region System.Object Members
7067

0 commit comments

Comments
 (0)