@@ -121,6 +121,11 @@ public string GetQuotedName(Dialect.Dialect d)
121
121
/// column name, and also take Dialect.MaxAliasLength into account.
122
122
/// </summary>
123
123
public string GetAlias ( Dialect . Dialect dialect )
124
+ {
125
+ return GetAlias ( dialect . MaxAliasLength ) ;
126
+ }
127
+
128
+ private string GetAlias ( int maxAliasLength )
124
129
{
125
130
string alias = _name ;
126
131
string suffix = UniqueInteger . ToString ( ) + StringHelper . Underscore ;
@@ -142,28 +147,30 @@ public string GetAlias(Dialect.Dialect dialect)
142
147
// reason, the checks for "quouted" and "rowid" looks redundant. If you remove
143
148
// those checks, then the double checks for total length can be reduced to one.
144
149
// But I will leave it like this for now to make it look similar. /Oskar 2016-08-20
145
- bool useRawName = _name . Length + suffix . Length <= dialect . MaxAliasLength &&
150
+ bool useRawName = _name . Length + suffix . Length <= maxAliasLength &&
146
151
! _quoted &&
147
152
! StringHelper . EqualsCaseInsensitive ( _name , "rowid" ) ;
148
153
if ( ! useRawName )
149
154
{
150
- if ( suffix . Length >= dialect . MaxAliasLength )
155
+ if ( suffix . Length >= maxAliasLength )
151
156
{
152
157
throw new MappingException (
153
158
string . Format (
154
159
"Unique suffix {0} length must be less than maximum {1} characters." ,
155
160
suffix ,
156
- dialect . MaxAliasLength ) ) ;
161
+ maxAliasLength ) ) ;
157
162
}
158
- if ( alias . Length + suffix . Length > dialect . MaxAliasLength )
159
- alias = alias . Substring ( 0 , dialect . MaxAliasLength - suffix . Length ) ;
163
+ if ( alias . Length + suffix . Length > maxAliasLength )
164
+ alias = alias . Substring ( 0 , maxAliasLength - suffix . Length ) ;
160
165
}
161
166
return alias + suffix ;
162
167
}
163
168
164
169
public string GetAlias ( Dialect . Dialect dialect , Table table )
165
170
{
166
- return GetAlias ( dialect ) + table . UniqueInteger + StringHelper . Underscore ;
171
+ string suffix = table . UniqueInteger . ToString ( ) + StringHelper . Underscore ;
172
+ int maxAliasLength = dialect . MaxAliasLength - suffix . Length ;
173
+ return GetAlias ( maxAliasLength ) + suffix ;
167
174
}
168
175
169
176
0 commit comments