@@ -121,6 +121,11 @@ public string GetQuotedName(Dialect.Dialect d)
121121 /// column name, and also take Dialect.MaxAliasLength into account.
122122 /// </summary>
123123 public string GetAlias ( Dialect . Dialect dialect )
124+ {
125+ return GetAlias ( dialect . MaxAliasLength ) ;
126+ }
127+
128+ private string GetAlias ( int maxAliasLength )
124129 {
125130 string alias = _name ;
126131 string suffix = UniqueInteger . ToString ( ) + StringHelper . Underscore ;
@@ -142,28 +147,30 @@ public string GetAlias(Dialect.Dialect dialect)
142147 // reason, the checks for "_quoted" and "rowid" looks redundant. If you remove
143148 // those checks, then the double checks for total length can be reduced to one.
144149 // 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 &&
146151 ! _quoted &&
147152 ! StringHelper . EqualsCaseInsensitive ( _name , "rowid" ) ;
148153 if ( ! useRawName )
149154 {
150- if ( suffix . Length >= dialect . MaxAliasLength )
155+ if ( suffix . Length >= maxAliasLength )
151156 {
152157 throw new MappingException (
153158 string . Format (
154159 "Unique suffix {0} length must be less than maximum {1} characters." ,
155160 suffix ,
156- dialect . MaxAliasLength ) ) ;
161+ maxAliasLength ) ) ;
157162 }
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 ) ;
160165 }
161166 return alias + suffix ;
162167 }
163168
164169 public string GetAlias ( Dialect . Dialect dialect , Table table )
165170 {
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 ;
167174 }
168175
169176
0 commit comments