@@ -17,21 +17,21 @@ public class Column : ISelectable, ICloneable
17
17
public const int DefaultPrecision = 19 ;
18
18
public const int DefaultScale = 2 ;
19
19
20
- private int ? length ;
21
- private int ? precision ;
22
- private int ? scale ;
20
+ private int ? _length ;
21
+ private int ? _precision ;
22
+ private int ? _scale ;
23
23
private IValue _value ;
24
- private int typeIndex = 0 ;
25
- private string name ;
26
- private bool nullable = true ;
27
- private bool unique = false ;
28
- private string sqlType ;
29
- private SqlType sqlTypeCode ;
30
- private bool quoted = false ;
31
- internal int uniqueInteger ;
32
- private string checkConstraint ;
33
- private string comment ;
34
- private string defaultValue ;
24
+ private int _typeIndex ;
25
+ private string _name ;
26
+ private bool _nullable = true ;
27
+ private bool _unique ;
28
+ private string _sqlType ;
29
+ private SqlType _sqlTypeCode ;
30
+ private bool _quoted ;
31
+ internal int UniqueInteger ;
32
+ private string _checkConstraint ;
33
+ private string _comment ;
34
+ private string _defaultValue ;
35
35
36
36
/// <summary>
37
37
/// Initializes a new instance of <see cref="Column"/>.
@@ -55,8 +55,8 @@ public Column(string columnName)
55
55
/// <value>The length of the datatype in the database.</value>
56
56
public int Length
57
57
{
58
- get { return length . GetValueOrDefault ( DefaultLength ) ; }
59
- set { length = value ; }
58
+ get { return _length . GetValueOrDefault ( DefaultLength ) ; }
59
+ set { _length = value ; }
60
60
}
61
61
62
62
/// <summary>
@@ -79,24 +79,24 @@ public int Length
79
79
/// </remarks>
80
80
public string Name
81
81
{
82
- get { return name ; }
82
+ get { return _name ; }
83
83
set
84
84
{
85
85
if ( value [ 0 ] == '`' )
86
86
{
87
- quoted = true ;
88
- name = value . Substring ( 1 , value . Length - 2 ) ;
87
+ _quoted = true ;
88
+ _name = value . Substring ( 1 , value . Length - 2 ) ;
89
89
}
90
90
else
91
91
{
92
- name = value ;
92
+ _name = value ;
93
93
}
94
94
}
95
95
}
96
96
97
97
public string CanonicalName
98
98
{
99
- get { return quoted ? name : name . ToLowerInvariant ( ) ; }
99
+ get { return _quoted ? _name : _name . ToLowerInvariant ( ) ; }
100
100
}
101
101
102
102
/// <summary>
@@ -112,7 +112,7 @@ public string CanonicalName
112
112
/// </returns>
113
113
public string GetQuotedName ( Dialect . Dialect d )
114
114
{
115
- return IsQuoted ? d . QuoteForColumnName ( name ) : name ;
115
+ return IsQuoted ? d . QuoteForColumnName ( _name ) : _name ;
116
116
}
117
117
118
118
/**
@@ -123,32 +123,32 @@ public string GetQuotedName(Dialect.Dialect d)
123
123
124
124
public string GetAlias ( Dialect . Dialect dialect )
125
125
{
126
- string alias = name ;
127
- string _unique = uniqueInteger . ToString ( ) + '_' ;
128
- int lastLetter = StringHelper . LastIndexOfLetter ( name ) ;
126
+ string alias = _name ;
127
+ string suffix = UniqueInteger . ToString ( ) + '_' ;
128
+ int lastLetter = StringHelper . LastIndexOfLetter ( _name ) ;
129
129
if ( lastLetter == - 1 )
130
130
{
131
131
alias = "column" ;
132
132
}
133
- else if ( lastLetter < name . Length - 1 )
133
+ else if ( lastLetter < _name . Length - 1 )
134
134
{
135
- alias = name . Substring ( 0 , lastLetter + 1 ) ;
135
+ alias = _name . Substring ( 0 , lastLetter + 1 ) ;
136
136
}
137
137
if ( alias . Length > dialect . MaxAliasLength )
138
138
{
139
- alias = alias . Substring ( 0 , dialect . MaxAliasLength - _unique . Length ) ;
139
+ alias = alias . Substring ( 0 , dialect . MaxAliasLength - suffix . Length ) ;
140
140
}
141
- bool useRawName = name . Equals ( alias ) &&
142
- ! quoted &&
143
- ! StringHelper . EqualsCaseInsensitive ( name , "rowid" ) ;
141
+ bool useRawName = _name . Equals ( alias ) &&
142
+ ! _quoted &&
143
+ ! StringHelper . EqualsCaseInsensitive ( _name , "rowid" ) ;
144
144
145
145
if ( useRawName )
146
146
{
147
147
return alias ;
148
148
}
149
149
else
150
150
{
151
- return alias + _unique ;
151
+ return alias + suffix ;
152
152
}
153
153
}
154
154
@@ -164,8 +164,8 @@ public string GetAlias(Dialect.Dialect dialect, Table table)
164
164
/// <value><see langword="true" /> if the column can have a null value in it.</value>
165
165
public bool IsNullable
166
166
{
167
- get { return nullable ; }
168
- set { nullable = value ; }
167
+ get { return _nullable ; }
168
+ set { _nullable = value ; }
169
169
}
170
170
171
171
/// <summary>
@@ -176,8 +176,8 @@ public bool IsNullable
176
176
/// </value>
177
177
public int TypeIndex
178
178
{
179
- get { return typeIndex ; }
180
- set { typeIndex = value ; }
179
+ get { return _typeIndex ; }
180
+ set { _typeIndex = value ; }
181
181
}
182
182
183
183
/// <summary>
@@ -186,8 +186,8 @@ public int TypeIndex
186
186
/// <value><see langword="true" /> if the column contains unique values.</value>
187
187
public bool IsUnique
188
188
{
189
- get { return unique ; }
190
- set { unique = value ; }
189
+ get { return _unique ; }
190
+ set { _unique = value ; }
191
191
}
192
192
193
193
/// <summary>
@@ -205,7 +205,7 @@ public bool IsUnique
205
205
/// </remarks>
206
206
public string GetSqlType ( Dialect . Dialect dialect , IMapping mapping )
207
207
{
208
- return sqlType ?? GetDialectTypeName ( dialect , mapping ) ;
208
+ return _sqlType ?? GetDialectTypeName ( dialect , mapping ) ;
209
209
}
210
210
211
211
private string GetDialectTypeName ( Dialect . Dialect dialect , IMapping mapping )
@@ -250,18 +250,18 @@ public bool Equals(Column column)
250
250
if ( null == column )
251
251
return false ;
252
252
253
- if ( this == column )
253
+ if ( ReferenceEquals ( this , column ) )
254
254
return true ;
255
255
256
- return IsQuoted ? name . Equals ( column . name ) : name . ToLowerInvariant ( ) . Equals ( column . name . ToLowerInvariant ( ) ) ;
256
+ return IsQuoted ? _name . Equals ( column . _name ) : _name . ToLowerInvariant ( ) . Equals ( column . _name . ToLowerInvariant ( ) ) ;
257
257
}
258
258
259
259
/// <summary>
260
260
/// Returns the hash code for this instance.
261
261
/// </summary>
262
262
public override int GetHashCode ( )
263
263
{
264
- return IsQuoted ? name . GetHashCode ( ) : name . ToLowerInvariant ( ) . GetHashCode ( ) ;
264
+ return IsQuoted ? _name . GetHashCode ( ) : _name . ToLowerInvariant ( ) . GetHashCode ( ) ;
265
265
}
266
266
267
267
#endregion
@@ -277,8 +277,8 @@ public override int GetHashCode()
277
277
/// </remarks>
278
278
public string SqlType
279
279
{
280
- get { return sqlType ; }
281
- set { sqlType = value ; }
280
+ get { return _sqlType ; }
281
+ set { _sqlType = value ; }
282
282
}
283
283
284
284
/// <summary>
@@ -287,34 +287,34 @@ public string SqlType
287
287
/// <value><see langword="true" /> if the column is quoted.</value>
288
288
public bool IsQuoted
289
289
{
290
- get { return quoted ; }
291
- set { quoted = value ; }
290
+ get { return _quoted ; }
291
+ set { _quoted = value ; }
292
292
}
293
293
294
294
/// <summary>
295
295
/// Gets or sets whether the column is unique.
296
296
/// </summary>
297
297
public bool Unique
298
298
{
299
- get { return unique ; }
300
- set { unique = value ; }
299
+ get { return _unique ; }
300
+ set { _unique = value ; }
301
301
}
302
302
303
303
/// <summary>
304
304
/// Gets or sets a check constraint on the column
305
305
/// </summary>
306
306
public string CheckConstraint
307
307
{
308
- get { return checkConstraint ; }
309
- set { checkConstraint = value ; }
308
+ get { return _checkConstraint ; }
309
+ set { _checkConstraint = value ; }
310
310
}
311
311
312
312
/// <summary>
313
313
/// Do we have a check constraint?
314
314
/// </summary>
315
315
public bool HasCheckConstraint
316
316
{
317
- get { return ! string . IsNullOrEmpty ( checkConstraint ) ; }
317
+ get { return ! string . IsNullOrEmpty ( _checkConstraint ) ; }
318
318
}
319
319
320
320
public string Text
@@ -334,14 +334,14 @@ public bool IsFormula
334
334
335
335
public int Precision
336
336
{
337
- get { return precision . GetValueOrDefault ( DefaultPrecision ) ; }
338
- set { precision = value ; }
337
+ get { return _precision . GetValueOrDefault ( DefaultPrecision ) ; }
338
+ set { _precision = value ; }
339
339
}
340
340
341
341
public int Scale
342
342
{
343
- get { return scale . GetValueOrDefault ( DefaultScale ) ; }
344
- set { scale = value ; }
343
+ get { return _scale . GetValueOrDefault ( DefaultScale ) ; }
344
+ set { _scale = value ; }
345
345
}
346
346
347
347
public IValue Value
@@ -361,20 +361,20 @@ public IValue Value
361
361
/// </remarks>
362
362
public SqlType SqlTypeCode
363
363
{
364
- get { return sqlTypeCode ; }
365
- set { sqlTypeCode = value ; }
364
+ get { return _sqlTypeCode ; }
365
+ set { _sqlTypeCode = value ; }
366
366
}
367
367
368
368
public string Comment
369
369
{
370
- get { return comment ; }
371
- set { comment = value ; }
370
+ get { return _comment ; }
371
+ set { _comment = value ; }
372
372
}
373
373
374
374
public string DefaultValue
375
375
{
376
- get { return defaultValue ; }
377
- set { defaultValue = value ; }
376
+ get { return _defaultValue ; }
377
+ set { _defaultValue = value ; }
378
378
}
379
379
380
380
public string GetTemplate ( Dialect . Dialect dialect , SQLFunctionRegistry functionRegistry )
@@ -384,7 +384,7 @@ public string GetTemplate(Dialect.Dialect dialect, SQLFunctionRegistry functionR
384
384
385
385
public override string ToString ( )
386
386
{
387
- return string . Format ( "{0}({1})" , GetType ( ) . FullName , name ) ;
387
+ return string . Format ( "{0}({1})" , GetType ( ) . FullName , _name ) ;
388
388
}
389
389
390
390
public SqlType GetSqlTypeCode ( IMapping mapping )
@@ -393,7 +393,7 @@ public SqlType GetSqlTypeCode(IMapping mapping)
393
393
try
394
394
{
395
395
SqlType sqltc = type . SqlTypes ( mapping ) [ TypeIndex ] ;
396
- if ( SqlTypeCode != null && SqlTypeCode != sqltc )
396
+ if ( SqlTypeCode != null && ! ReferenceEquals ( SqlTypeCode , sqltc ) )
397
397
{
398
398
throw new MappingException ( string . Format ( "SQLType code's does not match. mapped as {0} but is {1}" , sqltc , SqlTypeCode ) ) ;
399
399
}
@@ -402,14 +402,14 @@ public SqlType GetSqlTypeCode(IMapping mapping)
402
402
catch ( Exception e )
403
403
{
404
404
throw new MappingException ( string . Format ( "Could not determine type for column {0} of type {1}: {2}" ,
405
- name , type . GetType ( ) . FullName , e . GetType ( ) . FullName ) , e ) ;
405
+ _name , type . GetType ( ) . FullName , e . GetType ( ) . FullName ) , e ) ;
406
406
}
407
407
}
408
408
409
409
/// <summary>returns quoted name as it would be in the mapping file. </summary>
410
410
public string GetQuotedName ( )
411
411
{
412
- return quoted ? '`' + name + '`' : name ;
412
+ return _quoted ? '`' + _name + '`' : _name ;
413
413
}
414
414
415
415
public bool IsCaracteristicsDefined ( )
@@ -419,39 +419,39 @@ public bool IsCaracteristicsDefined()
419
419
420
420
public bool IsPrecisionDefined ( )
421
421
{
422
- return precision . HasValue || scale . HasValue ;
422
+ return _precision . HasValue || _scale . HasValue ;
423
423
}
424
424
425
425
public bool IsLengthDefined ( )
426
426
{
427
- return length . HasValue ;
427
+ return _length . HasValue ;
428
428
}
429
429
430
430
#region ICloneable Members
431
431
/// <summary> Shallow copy, the value is not copied</summary>
432
432
public object Clone ( )
433
433
{
434
434
Column copy = new Column ( ) ;
435
- if ( length . HasValue )
435
+ if ( _length . HasValue )
436
436
copy . Length = Length ;
437
- if ( precision . HasValue )
437
+ if ( _precision . HasValue )
438
438
copy . Precision = Precision ;
439
- if ( scale . HasValue )
439
+ if ( _scale . HasValue )
440
440
copy . Scale = Scale ;
441
441
copy . Value = _value ;
442
- copy . TypeIndex = typeIndex ;
442
+ copy . TypeIndex = _typeIndex ;
443
443
copy . Name = GetQuotedName ( ) ;
444
- copy . IsNullable = nullable ;
445
- copy . Unique = unique ;
446
- copy . SqlType = sqlType ;
447
- copy . SqlTypeCode = sqlTypeCode ;
448
- copy . uniqueInteger = uniqueInteger ; //usually useless
449
- copy . CheckConstraint = checkConstraint ;
450
- copy . Comment = comment ;
451
- copy . DefaultValue = defaultValue ;
444
+ copy . IsNullable = _nullable ;
445
+ copy . Unique = _unique ;
446
+ copy . SqlType = _sqlType ;
447
+ copy . SqlTypeCode = _sqlTypeCode ;
448
+ copy . UniqueInteger = UniqueInteger ; //usually useless
449
+ copy . CheckConstraint = _checkConstraint ;
450
+ copy . Comment = _comment ;
451
+ copy . DefaultValue = _defaultValue ;
452
452
return copy ;
453
453
}
454
454
455
455
#endregion
456
456
}
457
- }
457
+ }
0 commit comments