1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Linq ;
3
4
using System . Text . RegularExpressions ;
4
5
using NHibernate . Collection ;
5
6
using NHibernate . Engine ;
@@ -18,7 +19,7 @@ public class JoinWalker
18
19
private readonly HashSet < AssociationKey > visitedAssociationKeys = new HashSet < AssociationKey > ( ) ;
19
20
private readonly IDictionary < string , IFilter > enabledFilters ;
20
21
private readonly IDictionary < string , IFilter > enabledFiltersForManyToOne ;
21
- private static readonly Regex aliasRegex = new Regex ( @"( [\w]+)\. " , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
22
+ private static readonly Regex aliasRegex = new Regex ( @"[\w]+(?=\.) " , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
22
23
23
24
private string [ ] suffixes ;
24
25
private string [ ] collectionSuffixes ;
@@ -206,12 +207,12 @@ protected virtual SelectMode GetSelectMode(string path)
206
207
private static int [ ] GetTopologicalSortOrder ( List < DependentAlias > fields )
207
208
{
208
209
TopologicalSorter g = new TopologicalSorter ( fields . Count ) ;
209
- Dictionary < string , int > _indexes = new Dictionary < string , int > ( ) ;
210
+ Dictionary < string , int > indexes = new Dictionary < string , int > ( StringComparer . OrdinalIgnoreCase ) ;
210
211
211
212
// add vertices
212
213
for ( int i = 0 ; i < fields . Count ; i ++ )
213
214
{
214
- _indexes [ fields [ i ] . Alias . ToLower ( ) ] = g . AddVertex ( i ) ;
215
+ indexes [ fields [ i ] . Alias ] = g . AddVertex ( i ) ;
215
216
}
216
217
217
218
// add edges
@@ -222,9 +223,9 @@ private static int[] GetTopologicalSortOrder(List<DependentAlias> fields)
222
223
{
223
224
for ( int j = 0 ; j < dependentAlias . DependsOn . Length ; j ++ )
224
225
{
225
- var dependentField = dependentAlias . DependsOn [ j ] . ToLower ( ) ;
226
+ var dependentField = dependentAlias . DependsOn [ j ] ;
226
227
int end ;
227
- if ( _indexes . TryGetValue ( dependentField , out end ) )
228
+ if ( indexes . TryGetValue ( dependentField , out end ) )
228
229
{
229
230
g . AddEdge ( i , end ) ;
230
231
}
@@ -240,26 +241,26 @@ private static int[] GetTopologicalSortOrder(List<DependentAlias> fields)
240
241
/// </summary>
241
242
private void AddAssociation ( string subalias , OuterJoinableAssociation association )
242
243
{
243
- subalias = subalias . ToLower ( ) ;
244
+ var dependentAlias = new DependentAlias
245
+ {
246
+ Alias = subalias ,
247
+ } ;
248
+ _dependentAliases . Add ( dependentAlias ) ;
244
249
245
- var dependencies = new List < string > ( ) ;
246
250
var on = association . On . ToString ( ) ;
247
- if ( ! String . IsNullOrEmpty ( on ) )
251
+ if ( ! string . IsNullOrEmpty ( on ) )
248
252
{
253
+ var dependencies = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
249
254
foreach ( Match match in aliasRegex . Matches ( on ) )
250
255
{
251
- string alias = match . Groups [ 1 ] . Value ;
252
- if ( alias == subalias ) continue ;
253
- dependencies . Add ( alias . ToLower ( ) ) ;
256
+ string alias = match . Value ;
257
+ if ( string . Equals ( alias , subalias , StringComparison . OrdinalIgnoreCase ) )
258
+ continue ;
259
+ dependencies . Add ( alias ) ;
254
260
}
261
+ dependentAlias . DependsOn = dependencies . ToArray ( ) ;
255
262
}
256
263
257
- _dependentAliases . Add ( new DependentAlias
258
- {
259
- Alias = subalias ,
260
- DependsOn = dependencies . ToArray ( )
261
- } ) ;
262
-
263
264
associations . Add ( association ) ;
264
265
}
265
266
0 commit comments